Dynamic caching for persistent session
Consider an example of dynamic caching for persistent session: The Remember Me feature is enabled, and a guest customer returned to the store. The Remember Me (persistent session) feature in WebSphere Commerce does not require the first request that is processed by the WebSphere Commerce Server to be skipped by the dynamic caching facility and processed during run time. The only caching requirement is that any request that displays user-oriented data must be processed once by the WebSphere Commerce run time before it displays this data. Since pages that contain data that pertains to a particular user are not typically cached, it is acceptable to delay generating the new guest customer until a non-cacheable operation is requested where a new guest customer is created and then migrated.
Since dynamic caching does not ignore a request when a cookie does not exist, a temporary cookie is created for the first request processed by the WebSphere Commerce run time. All subsequent requests are then marked as repeat requests. This cookie, named WC_SESSION_ESTABLISHED, has a constant value of true once created. Having a constant value across multiple session means that this cookie can be used as part of the cache key. Defining a cache entry in the cachespec.xml file, as shown in this example, ensures that only cached pages are used if this cookie exists.
<cache-id>
<component id="" type="pathinfo">
<required>true</required>
<value>/StoreCatalogDisplay</value>
</component>
<component id="WC_SESSION_ESTABLISHED" type="cookie">
<required>true</required>
</component>
<component id="storeId" type="parameter">
<required>true</required>
</component>
<component id="catalogId" type="parameter">
<required>true</required>
</component>
</cache-id>
You can skip caching the first request only and if it is the first request processed by the WebSphere Commerce Server, and not the first request for each store of the WebSphere Commerce Server. If the WebSphere Commerce instance has multiple stores that are enabled and the customer goes to one store and then the other, this cookie is generated at the first request for the first store. It means that cookie exists when the request is made to the second store and the cache version of the request is used.