Tutorials > Dynamic caching > Use dynacache's API to not cache

< Previous


Use dynacache's API to not cache a fragment on a page

This section is related to using dynacache's API to not cache a fragment on a page.

It might be unsuitable to cache a section of a page for which consume-subfragments=true. For example, suppose the eMarketingSpot was truly dynamic, and updated on each refresh of the page using personalized data. In this case, do not cache the eMarketingSpot fragment at all.

While this behavior cannot be achieved through the use of cachespec.xml, you can accomplish this with the Dynacache API.


Procedure

  1. Comment out the eMarketingSpot fragment rule from cachespec.xml.

  2. You can look at the contents in the cache for TopCategoriesDisplay to ensure that the fragment is getting cached with the full-page entry.

  3. Add the following code to the top of WC_EAR\Stores.war\ store_name\include\eMarketingSpotDisplay.jsp so that it is not cached.

    <%@ page import="com.ibm.websphere.servlet.cache.*" %>
    <%
    ((ServletCacheResponse)response).setDoNotConsume(true);
    %>
    

  4. Verify the eMarketingSpot is no longer cached.

    1. Clear the cache entries.

    2. Hit TopCategoriesDisplay.

    3. Examine the cached content for the TopCategoriesDisplay page to verify the eMarketingSpot is no longer cached with it.

< Previous


+

Search Tips   |   Advanced Search