Tutorial: Using dynacache's API to not cache >
< Previous | Next >

 

Use dynacache's API to not cache a full page matching a caching rule


This section is about using dynacache's API to not cache a full page matching a caching rule.
There are some circumstances where you do not cache a page, even though it matches a rule in the cachespec. To illustrate the technique, you will make the TopCategoriesDisplay page not cacheable.

  1. Add code to the TopCategoriesDisplay page so that this page will not be cached.

    1. Open WC_eardir\Stores.war\ store_name\ShoppingArea\CatalogSection\CategorySubsection\TopCategoriesDisplay.jsp

    2. Add the following code to the top of the JSP page:
      <%@ page
      import="com.ibm.commerce.webcontroller.HttpControllerRequestObject"
      %>
      <%@ page import="javax.servlet.http.HttpServletRequest" %>
      <%@ page import="com.ibm.commerce.server.JSPHelper" %>
      <%@ page import="com.ibm.commerce.command.CommandContext" %>
      <%
      
      
      CommandContext commandContext =
      (CommandContext)request.getAttribute("CommandContext");
      HttpControllerRequestObject controllerReq =
      (HttpControllerRequestObject)commandContext.getRequest();
      HttpServletRequest req = controllerReq.getHttpRequest();
      JSPHelper.setUncacheable(req,true);
      
      %>
      
      
      

  2. Verify that the TopCategoriesDisplay page is not being cached.

    1. Use the cache monitor to clear the cache entries.

    2. Hit the TopCategoriesDisplay page.

    3. View the cached entries using the cache monitor - there is no entry for the TopCategoriesDisplay.

  3. Remove the code from the JSP file so that TopCategoriesDisplay will be cached again.


< Previous | Next >