Wednesday, September 5, 2012

Dynacache Tip: Exclude JSP fragment from cache

Scenario:

1. You are caching a JSP in cachespec.xml, lets call it "parent.jsp".
2. You have configured "parent.jsp" to consume sub-fragments.
3. There is a JSP being included by parent.jsp, lets call it "child.jsp"
4. The file is being included using the <c:import> tag
5. You don't want to cache child.jsp at all
6. You don't want parent.jsp to consume child.jsp into its cache

Solution:

Add the following line in child.jsp:

<% ((com.ibm.websphere.servlet.cache.ServletCacheResponse)response).setDoNotConsume(true); %>

This way gets around having to add child.jsp to cachespec.xml and setting do-not-consume=true.

No comments:

Post a Comment