Bootstrap FreeKB - IBM WebSphere - Dynamic caching
IBM WebSphere - Dynamic caching

Updated:   |  IBM WebSphere articles

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.

  1. In the left panel of the WebSphere web console, expand Servers > Server types.
  2. Select WebSphere application servers.
  3. Select an application server.
  4. Expand Web Container Settings and select Web container.
  5. Check Enable servlet and command caching and select OK.
  6. Select Save.
  7. Restart the JVM.

 

By default, the Dynamic cache service is enabled.

  1. In the left panel of the WebSphere web console, expand Servers > Server types.
  2. Select WebSphere application servers.
  3. Select an application server.
  4. Expand Container Settings and select Dynamic cache service.

 

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.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


August 12 2020 by Sunitha
I have doubt regard this could you solve it?how we can clear the dyna cache using command (wasadmin command )

Add a Comment


Please enter e622be in the box below so that we can be sure you are a human.