IBM WCS ( Websphere Commerce Suite ) - Ways to avoid caching of pages / Invalidate Page Caching



The Simplest way is to remove the JSP entry from cachespec.xml 

but it would mean that no page being generated out of this jsp will be cached.

If you are looking for invalidating caching for specific pages on the basis of server side condition you can use following -

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


Another good way one can use to avoid caching on the basis of url parameter is by having a filter / interceptor -

String dontCache = request.getParameter("dontcache");

if (!StringUtils.isEmpty(dontCache) && noCache.equalsIgnoreCase(dontCache)) {
JSPHelper.setUncacheable(((HttpServletRequest)request), true);
}

So now you can set the parameter dontcache=true for all pages which you don't want to be cached.