|
Problem |
Behavior of the do-not-consume property when specified in
the cachespec.xml |
|
Solution |
Do-not-consume in Dynamic Cache
Property
|
Valid classes
|
Value
|
do-not-consume |
Servlet or Web service |
True or false. Default is false. When a
fragment parent has the consume-subfragment property set to true the child
fragment content is saved in the cache entry of the parent. Do-not-consume
(DNC) tells the cache to stop saving the content for this fragment in the
parent cache-entry and create a placeholder instead for the include or
forward. |
A <cache-entry> element without a <cache-id> is
not a valid case because Dynamic Cache would be unable to generate a
cache-id to determine if the fragment is cacheable. You can add a simple
cache-id that only contains a timeout or priority. The following cache-id
will be matched for all requests:
For example:
<cache-id>
<priority>2</priority>
</cache-id>
When using do-not-consume the fragment is not consumed by the parent but
it is still cached as a separate entry in cache. This means that on
subsequent requests you will still get a cache-hit for the child fragment
when the parent performs the include.
do-not-consume function designed to reduce the whole page invalidations
that occur because of dependencies on the children fragments.
In case of child fragment not be consumed by the parent and also not
cached at all you would need to have a cache policy that specifies a very
small timeout for the fragment marked do-not-consume so that the cached
entry will timeout before the next request.
For example:
<cache-entry>
<class>servlet</class>
<name>/output.jsp</name>
<property
name="do-not-consume">true</property>
<cache-id>
<timeout>1</timeout>
</cache-id>
</cache-entry>
Another option outside of configuring cachespec.xml would be to use the
com.ibm.websphere.servlet.cache.ServletCacheResponse.setDoNotConsume()
API:
/**
* This sets the page to not be consumed by its parents
* @param value True if the page is to be set as do-not-consume
* @ibm-api
*/
public void setDoNotConsume(boolean doNotConsume);
If no cache policy is created for the child fragment and you call
setDoNotConsume(true) then the child fragment will not be consumed by its
parents and also will not be cached. |
|
|
|
Cross Reference information |
Segment |
Product |
Component |
Platform |
Version |
Edition |
Application Servers |
Runtimes for Java Technology |
Java SDK |
|
|
|
|