Configuring cacheable objects

Cacheable objects are defined inside the cachespec.xml file, found inside the Web application archive (WAR) WEB-INF or enterprise bean WEB-INF directory. You can place a global cachespec.xml file in the application server properties directory, but the recommended method is to place the cache configuration file with the deployment module. The root element of the cachespec.xml file is <cache>, which contains <cache-entry> elements.

To specify the cache entry for servlet or JSP result caching, add the following section to the cachespec.xml file:

<cache-entry>
  <class>servlet</class>
  <name>name</name>
  ...
</cache-entry>

where name is the relative Web path or servlet mapping of the servlet or JSP

To specify the cache entry for command caching, add the following section to the cachespec.xml file:

<cache-entry>
  <class>command</class>
  <name>name</name>
  ...
</cache-entry>

where name is the complete path to the command class, for example, com.ibm.commerce.dynacache.commands.MemberGroupsCacheCmdImpl.

Within a <cache-entry>...</cache-entry> element, you can develop cache-ID, dependency-ID, and invalidation rules. To cache an object, WebSphere Application Server has to be able to generate unique IDs for different invocations of that object. The <cache-id> element performs this task. Each cache entry can have multiple cache-ID rules that execute in order until either a rule returns a non-empty cache-ID or no more rules remain to execute. If none of the cache-ID generation rules produce a valid cache ID, then the object is not cached.

Note: For this release, when specifying the cache entry for command caching, only command invalidation using the <invalidate>...</invalidate> is supported. (You cannot use the <cache-id>...</cache-id> or <dependency-id>...</dependency-id> elements for command caching.)

<cache-entry> <class>command</class> <name>name</name> <invalidate> ... </invalidate> </cache-entry>

The dynamic cache responds to changes in the cachespec.xml file. When new versions of cachespec.xml are detected, the old policies are replaced. Objects cached through the old policy file are not automatically invalidated from the cache. They are either reused with the new policy or eliminated from the cache through its replacement algorithm. For more information about the cachespec.xml file, see the topic "Cachespec.xml file" in the WebSphere Application Server Information Center. In addition, see the topic "Creating store pages that can be cached" in the WebSphere Commerce Developer information center for additional considerations when developing your store.

Note: For requests using the PVC adapter (for a pervasive computing device), you can only use the URL parameters as the cache keys.

Caching defaults

During installation, WebSphere Commerce sets up the caching system with the following defaults:

Feedback