Technote (troubleshooting)
Problem(Abstract)
Getting the JSP file fragments cached is possible, but invalidations are not working for some cached fragments. Dynacache invalidations not working for some cached JSP file fragments due to insertion of hex characters in the cachespec.xml file
Symptom
Stale content is displayed on site
Cause
The following example from the cachespec.xml file shows how a caching and invalidation policy has been set up for the MiniCart.jsp file. This JSP file gets cached after the first request but the invalidation for this fragment is not working:
*************************Cache Rule*****************************
<cache-entry>
<class>servlet</class>
<name>/<jsp-path>/MiniCart.jsp</name>
<property name="store-cookies">false</property>
<property name="save-attributes">false</property>
<property name="do-not-consume">true</property>
<property name="ignore-get-post">true</property>
<property name="ignore-get-post">true</property>
<cache-id>
<component id="storeId" type="parameter">
<required>false</required>
</component>
<component id="DC_userId" type="attribute">
<required>true</required>
</component>
</cache-id>
<dependency-id>MiniCart
<component id="DC_userId" type="attribute">
<required>true</required>
</component>
</dependency-id>
</cache-entry>
*************************Cache Rule*****************************
*************************Invalidation Rule*****************************
<cache-entry>
<class>command</class>
<sharing-policy>not-shared</sharing-policy>
<name>com.ibm.commerce.order.commands.OrderCalculateCmdImpl</name>
<name>com.ibm.commerce.order.commands.PromotionEngineOrderCalculateCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.OrderItemMoveCmdImpl</name>
<name>com.ibm.commerce.usermanagement.commands.UserRegistrationAddCmdImpl</name>
<name>com.ibm.commerce.usermanagement.commands.UserRegistrationUpdateCmdImpl</name>
<name>com.ibm.commerce.order.commands.OrderProcessCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.OrderItemAddCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.OrderItemDeleteCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.OrderItemUpdateCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.ExternalOrderItemAddCmdImpl</name>
<name>com.ibm.commerce.orderitems.commands.ExternalOrderItemUpdateCmdImpl</name>
<name>com.ibm.commerce.order.commands.OrderCancelCmdImpl</name>
<name>com.ibm.commerce.order.commands.SetPendingOrderCmdImpl</name>
<invalidation>MiniCart
<component type="method" id="getCommandContext">
<method>getUserId</method>
<required>true</required>
</component>
</invalidation>
</cache-entry>
*************************Invalidation Rule*****************************
Resolving the problem
Invisible characters might be inserted into the file. These characters are visible when the editor is in Hex mode. This can potentially occur when files are copied between different platforms.
The invalidation rule shown is:
..
..
<invalidation>MiniCart
<component type="method" id="getCommandContext">
<method>getUserId</method>
<required>true</required>
</component>
</invalidation>
</cache-entry>
If there are hex characters inserted between the 'MiniCart' and '<component' (highlighted above), the invalidations for MiniCart.jsp will not work.
Examining the cachespec.xml file in Hex mode reveals if there are any hex characters after 'MiniCart'.
Alternatively, dynacache tracing shows the full constructed invalidation-id and if this ID has any spaces in it, the problem is caused by hex characters in the cachespec.xml file.
Here is the dynacache tracing to enable:
com.ibm.ws.cache.*=all
If cache replication is enabled in a clustered environment, enable the following trace instead:
com.ibm.ws.cache.*=all:com.ibm.ws.drs.*=all
In the trace, if you see a space in invalidation-id as shown below, this is caused by hex characters after MiniCart in the cachespec.xml file:
[10/29/12 13:12:17:963 EDT] 0000007e Cache > Cache.internalInvalidateById: cacheName=baseCache id=MiniCart :12345 Entry
[10/29/12 13:12:17:963 EDT] 0000007e Cache 3 Cache.remove() cacheName=baseCache id=MiniCart :12345 cause=1 source=5
[10/29/12 13:12:17:963 EDT] 0000007e Cache < Cache.internalInvalidateById: cacheName=baseCache id=MiniCart :12345 rc=false Exit
[10/29/12 13:12:17:963 EDT] 0000007e ExternalCache 3 ExternalCacheServices.invalidate id: MiniCart :12345
Invalidation-id should be:
MiniCart:12345
Instead of:
MiniCart :12345
This problem is fixed by removing the space after 'MiniCart' as shown below:
<invalidation>MiniCart<component type="method" id="getCommandContext">
<method>getUserId</method>
<required>true</required>
</component>
</invalidation>
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.