Step 1: Defining the cache policy

This section of the tutorial is designed to illustrate through examples, the steps involved in defining a cache policy. By the end of this section you will be able to:

  1. Publish your store or store archive
  2. Define the cache policy

Publishing your store or store archive

After you have successfully created a WebSphere Commerce instance, you can publish a starter store. To follow steps to publish a starter store, see Publishing a store archive. In this case, select the Advanced B2B Direct store for publishing.

Defining the cache policy

After you have published the starter store, you can begin to define your cache policy. In order for dynamic cache to cache servlets and JSP page results, the cache-entry element has to be defined in the cache policy configuration file (cachespec.xml).

For caching servlet and JSP page results, you must do the following:

For example:

<name>com.ibm.commerce.server.RequestServlet.class</name>
<name>/ToolTech/ShoppingArea/CatalogSection/CategorySubsection/StoreCatalogDisplay.jsp</name>

Note: WebSphere Commerce has only one controller servlet for the Stores.war named com.ibm.commerce.server.RequestServlet.class. Therefore, when caching with the servlet class, a filtering mechanism is needed to determine what needs to be cached. This can be accomplished by using the attribute type pathinfo in the component sub-element in the cache-id specification. For example:

<component id="" type="pathinfo">
  <required>true</required>
  <value>/StoreCatalogDisplay</value>
</component>

For more details on defining cache policy using the cachespec.xml file, see Configuring cacheable objects.

Caching full pages

If the web page you have selected can be cached as a whole page, the cache-entry element will have to be specified for that intention. See Full page and fragment caching for examples of that specification. Copy and paste the code samples from that page into your cachespec.xml file.

Caching page fragments

See Full page and fragment caching for examples of caching page fragments. Copy and paste the code samples from that page into your cachespec.xml file.

Defining cache IDs

Each cache-id element defines a rule for caching an object and is composed of the following sub-elements:

When defining cache IDs for cache-entry, you must take into consideration how the servlet and JSP page result output will be cached. If full page caching is being used for the WebSphere Commerce command, then the command parameters will be the key factor for defining the cache ID rules. If the page output is to be cached by JSP pages, then the parameters for the JSP pages are the key. Also in some cases, the request attributes set by the cache filter should also be used to define the rules. For example, if some session information like the user's preferred language and currency are a mandatory key to make the cache ID unique.

Feedback