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.
- Add code to the TopCategoriesDisplay page so that this page will not be cached.
- Open WC_eardir\Stores.war\ store_name\ShoppingArea\CatalogSection\CategorySubsection\TopCategoriesDisplay.jsp
- 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); %>
- Verify that the TopCategoriesDisplay page is not being cached.
- Use the cache monitor to clear the cache entries.
- Hit the TopCategoriesDisplay page.
- View the cached entries using the cache monitor - there is no entry for the TopCategoriesDisplay.
- Remove the code from the JSP file so that TopCategoriesDisplay will be cached again.