In the past, a web server or application server would only cache static content, such as HTML files, CSS stylesheets, and images. Dynamic caching configures WebSphere to also cache dynamic content, such as Java servlets. For example, let's say you have a servlet called "Sample" that displays "Hello World". The Sample servlet can be cached, so that subsequent requests for the Sample servlet are returned from the WebSphere cache.
The cachespec.xml file is used to configure the servlets that will be cached. The cachespec.xml file can be placed in the was_home/profiles/your_profile/properties files, or in the applications WEB-INF folder. The cachespec.xml file in the properties directory is considered a global configuration file, meaning that the settings in the global configuration file apply to every application in the cell. Configurations in the cachespec.xml file in the WEB-INF folder will override the global cachespec.xml file.
In this example, the cachespec.xml file is configured to cache the Sample servlet for 30 minutes. If the application is deployed to a cluster, cached objects will be shared across the the application servers in the cluster.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xml> <cache> <cache-entry> <class>servlet</class> <name>Sample</name> <sharing-policy>shared-push</sharing-policy> <cache-id> <timeout>30</timeout> </cache-id> </cache-entry> </cache>
Configure the JVM to cache servlets and commands.
By default, the Dynamic cache service is enabled.
When a JVM is started, the JVMs SystemOut.log can be used to confirm if the cachespec.xml file was loaded into the JVMs memory.
DYNA0062I: Successfully loaded cache-instances from cache configuration file was_home/profiles/your_profile/properties/cachespec.xml. DYNA0047I: Successfully loaded cache-entries from cache configuration file was_home/profiles/your_profile/properties/cachespec.xml.
Now you are ready to start managing the cache. Almost always, you will do the management using the Cache Monitor application. However, it is worth noting that you can view some reporting on the dynamic cache at Monitoring and Tuning > Performance Monitor > current activity > your server.