Behavior of dynamic cache with URI based caching for Servlets and JSPs
 Technote (troubleshooting)
 
Problem(Abstract)
Behavior of dynamic cache for URI's, servletpath and pathinfo based cache policies.
 
Cause
WebSphere® Application Server V5.0 and V5.1 have improved functionality of the dynamic cache service, to adopt new improvements, cachespec.xml file should be used to configure cache policy.
 
Resolving the problem
You can specify either a URI or classname in the <name> </name> field of the cache policy. If you specify the URI, dynamic cache uses that cache policy for a given request only if the request URI (servletpath + pathinfo) matches the one specified in the <name> </name> field.

For example following request will be cached if name field looks like
<name>/Snoop/test</name>
http://localhost:9080/Snoop/test


On the other hand, if you specify the class name in the <name> </name> field, dynamic cache is going use that cache policy for every request that maps to that servlet class irrespective of the servletpath and pathinfo. So if you change cache policy to one shown below, all the following URLs will be cached.
http://localhost:9080/Snoop/test http://localhost:9080/Snoop/ http://localhost:9080/Snoop/aaa?test=1 http://localhost:9080/Snoop/aaa/test


<cache-entry>
<class>servlet</class>
<name>Snoop.class</name>
<cache-id>
<component id="test" type="parameter">
<required>false</required>
</component>
<component id="*" type="pathinfo">
<required>false</required>
</component>
<component id="*" type="servletpath">
<required>false</required>
</component>
<timeout>3600</timeout>
</cache-id>
</cache-entry>


WebSphere Application Server V5.1.1.2 added support to servlets for multiple <cache-entry>...</cache-entry> tags. Earlier there was support for only one cache policy per servlet.

For example for following two cache policies:

<cache-entry>
<class>servlet</class>
<name>/Snoop</name>
<cache-id>
<component id="test" type="parameter">
<required>false</required>
</component>
<component id="*" type="pathinfo">
<required>false</required>
</component>
<component id="*" type="servletpath">
<required>false</required>
</component>
<timeout>3600</timeout>
</cache-id>
</cache-entry>

<cache-entry>
<class>servlet</class>
<name>/Snoop/test</name>
<cache-id>
<component id="test" type="parameter">
<required>false</required>
</component>
<component id="*" type="pathinfo">
<required>false</required>
</component>
<component id="*" type="servletpath">
<required>false</required>
</component>
<timeout>3600</timeout>
</cache-id>
</cache-entry>


The following URLs will be cached:http://localhost:9080/Snoop/test?aaa=1 http://localhost:9080/Snoop/test http://localhost:9080/Snoop http://localhost:9080/Snoop?test=1


The following URL will NOT be cached:
http://localhost:9080/Snoop/test/aaa http://localhost:9080/Snoop/test/aaa?test=1

 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Dynamic Cache
Operating system(s): Windows
Software version: 5.1
Software edition:
Reference #: 1198257
IBM Group: Software Group
Modified date: Sep 12, 2007