Home


8.3.2 TopCategoriesDisplay

TopCategoriesDisplay displays the root categories for a catalog. ConsumerDirect uses this URL as the home page for the store Web site. The URL structure and parameter values are shown in Figure | -9.

Figure 8-9 TopCategoriesDisplay

Table | -4 explains the parameter values that are used by the TopCategoriesDisplay URL.

Table 8-4

Parameter name Description
langId Sets or resets the preferred language for the duration of the session. The supported languages for a store are found in the STORELANG table.
storeId (Required) The reference number of the store associated with the categories.
catalogId The reference number for the catalog that is associated with the given store. The catalog contains root categories.
identifier The external identifier for the category.
memberId The reference number of the member who owns the category. The memberId along with the identifier uniquely identify the category. If a memberId is omitted, then the owner of the current store along with the identifier are used to uniquely identify the category.

TopCategoriesDisplay parameter values

By default ConsumerDirect uses the following parameters:

StoreId

CatalogId

CategoryId (ConsumerDirect store specific parameter)

Based on this information, add the cache-id for TopCategoriesDisplay shown in Example | -2.

Example 8-2 TopCategoriesDisplay cache-id

<cache-id>

 <component id="" type="pathinfo">
  <required>true</required>
  <value>/TopCategoriesDisplay</value>
 </component>

 <component id="storeId" type="parameter">
  <required>true</required>
 </component>

 <component id="catalogId" type="parameter">
  <required>true</required>
 </component>

 <component id="categoryId" type="parameter">
  <required>false</required>
 </component>

</cache-id>

Now check that cachespec.xml is loaded correctly by verifying the TopCategoriesDisplay cache policy in Cache Monitor.

1. Check that cachespec.xml is reloaded.

a. Point your Web browser to the Cache Monitor:

http://host_name/cachemonitor

b. Navigate to Cache Policies Æ /webapp/wcs/stores/ com.ibm.commerce.struts.ECActionServlet.class.

c. You will see the TopCategoriesDisplay cache policy that you defined. It should look like Figure | -10.

Figure 8-10 TopCategoriesDisplay cache policy

2. Verify that TopCategoriesDisplay URL is being cached.

a. Clear any existing cache and reset statistics using Cache Monitor by selecting Cache Monitor Æ Cache Statistics Æ Clear Cache Æ Reset Statistics.

b. The cache statistics are reset as shown in Figure | -11.

Figure 8-11 Cache Statistics

c. Open a new Web browser and point to the ConsumerDirect home page:

http://host_name/webapp/wcs/stores/servlet/TopCategoriesDisplay?langId=-1&storeId=10001&catalogId=10001

The home page is shown in Figure | -12.

Figure 8-12 ConsumerDirect Home page

d. Refresh the Cache Monitor to view updated statistics. You will see some Cache Misses because the cache was cleared. This is shown in Figure | -13.

Figure 8-13 Cache Statistics after TopCategoriesDisplay call

3. Find the fragments that we do not want to consume with the full page.

a. Navigate to this cached page using Cache Monitor and selecting Cache Contents Æ .../ECActionServlet.class Template Æ ...:pathinfo=/TopCategoriesDisplay Cache ID.

b. To find the included JSPs that are consumed with this full page cache, look for the "CONSUMED include" term.

i. You will find the first entry for TopCategoriesDisplay.jsp. This is the parent JSP and we want it to be consumed - this is the correct behavior.

ii. CachedHeaderDisplay.jsp is the second JSP that is consumed.

CachedHeaderDisplay.jsp is a dynamic fragment that causes the home page content to change when a user logs in. However, it is cached with the TopCategoriesDisplay page. The result is that the home page content does not change when the TopCategoriesDisplay page is displayed again. When another user logs in and displays the TopCategoriesDisplay page, the CachedHeaderDisplay is loaded from the cache and displays the previous user's details.

To correct this stop CachedHeaderDisplay.jsp from being consumed by TopCategoriesDisplay. Create a new cache-entry in your cachespec.xml file as shown in Example | -3.

Example 8-3 CachedHeaderDisplay.jsp cache-entry

<cache-entry>

 <class>servlet</class>
 <name>/ConsumerDirect/include/styles/style1/CachedHeaderDisplay.jsp</name>
 <name>/ConsumerDirect/include/styles/style2/CachedHeaderDisplay.jsp</name>
 <property name="do-not-consume">true</property>
 <property name="save-attributes">false</property>

 <cache-id>

  <component id="storeId" type="parameter">
   <required>true</required>
  </component>

  <component id="catalogId" type="parameter">
   <required>true</required>
  </component>

  <component id="DC_userType" type="attribute">
   <required>false</required>
   <not-value>-1002</not-value>
  </component>

  <component id="DC_lang" type="attribute">
   <required>true</required>
  </component>

 </cache-id>

</cache-entry>

iii. Continue to search for more consumed fragments in Cache Monitor.

The next entry is MiniShopCartDisplay.jsp.

MiniShopCartDisplay.jsp displays the number of items in the user cart and the subtotal. We handle the caching of this JSP fragment differently from the rest of the page. Use command-based invalidation to re-cache the MiniShopCartDisplay.jsp every time the user makes a change to their shopping cart.

Add the snippet shown in Example | -4 to the cachespec.xml file.

Example 8-4 /MiniShopCartDisplay.jsp

<cache-entry>
 <class>servlet</class>
 <name>/ConsumerDirect/include/MiniShopCartDisplay.jsp</name>
 <property name="do-not-consume">true</property>
 <property name="save-attributes">false</property>
 <cache-id>
  <component id="DC_storeId" type="attribute">
   <required>true</required>
  </component>
  <component id="DC_userId" type="attribute">
   <required>false</required>
   <not-value>-1002</not-value>
  </component>
  <component id="DC_lang" type="attribute">
   <required>true</required>
  </component>
  <component id="DC_curr" type="attribute">
   <required>true</required>
  </component>
  <priority>1</priority>
  <timeout>3600</timeout>
  <inactivity>600</inactivity>  
 </cache-id>
 <dependency-id>DC_storeId
  <component id="DC_storeId" type="attribute">
   <required>true</required>
  </component>
 </dependency-id>
 <dependency-id>DC_userId
  <component id="DC_userId" type="attribute">
    <required>true</required>
  </component>
 </dependency-id>
 <dependency-id>MiniCart</dependency-id>
 <dependency-id>MiniCart:DC_storeId
  <component id="DC_storeId" type="attribute">
    <required>true</required>
  </component>
 </dependency-id>
 <dependency-id>MiniCart:DC_userId
  <component id="DC_userId" type="attribute">
    <required>true</required>
  </component>
 </dependency-id>
 <dependency-id>MiniCart:DC_storeId:DC_userId
  <component id="DC_storeId" type="attribute">
    <required>true</required>
  </component>
  <component id="DC_userId" type="attribute">
    <required>true</required>
  </component>
 </dependency-id>
</cache-entry>

<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>
 <!-- Used by the advanced order  -->
 <name>com.ibm.commerce.order.commands.OrderProcessCOCmdImpl</name>
 <name>com.ibm.commerce.orderitems.commands.OrderItemAddCOCmdImpl</name>
 <name>com.ibm.commerce.orderitems.commands.OrderItemDeleteCOCmdImpl</name>
 <name>com.ibm.commerce.orderitems.commands.OrderItemUpdateCOCmdImpl</name>
 <name>com.ibm.commerce.order.commands.OrderCancelCOCmdImpl</name>
 <!-- Used by the classic order  -->
 <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.order.commands.OrderCancelCmdImpl</name>

 <invalidation>MiniCart:DC_storeId:DC_userId
  <component type="method" id="getCommandContext">
   <method>getStoreId</method>
   <required>true</required>
  </component>
  <component type="method" id="getCommandContext">
   <method>getUserId</method>
   <required>true</required>
  </component>
 </invalidation>
</cache-entry>

iv. Continue to search for more consumed fragments in Cache Monitor.

The next fragment is CachedSidebarDisplay.jsp.

This stays constant and is best left being consumed with the page for better performance.

v. The next fragments in the Cache Monitor are ContentContainerTop.jsp and ContentSpotDisplay.jsp.

These can be added to cachespec.xml by navigating to WebSphere Commerce Accelerator by selecting ConsumerDirect Æ Store Æ Content Æ Home spot - Top and/or Bottom.

If the home spots are updated frequently, it is better to cache this fragment separately by adding an entry as shown in Example | -5.

Example 8-5 ContentContainerTop.jsp

<cache-entry>
 <class>servlet</class>
 <name>/ConsumerDirect/Snippets/Marketing/Content/ContentSpotDisplay.jsp</name>
 <property name="do-not-consume">true</property>
 <property name="save-attributes">false</property>
 <cache-id>
  <component id="emsName" type="parameter">
   <required>true</required>
  </component>
  <component id="DC_storeId" type="attribute">
   <required>true</required>
  </component>
  <component  id="DC_lang" type="attribute">
   <required>true</required>
  </component>
  <inactivity>600</inactivity>
 </cache-id>
</cache-entry>

vi. Continue to search for more consumed fragments in Cache Monitor.

The next entry is for StoreCatalogProductESpot.jsp. This alternates the eSpots on the main page. In order to avoid consuming these with TopCategoriesDisplay, so that the eSpots change, add the cache-entry shown in Example | -6 to cachespec.xml file.

Example 8-6 StoreCatalogProductESpot.jsp

<cache-entry>
 <class>servlet</class>
 <name>/ConsumerDirect/include/StoreCatalogProductESpot.jsp</name>
 <property name="do-not-cache">true</property>
 <cache-id>
 </cache-id>
</cache-entry>

vii. The last fragment is CachedFooterDisplay.jsp. If the footer is session dependant then follow Example | -7 and cache CachedFooterDisplay.jsp separately.

Example 8-7 CachedFooterDisplay.jsp

<cache-entry>
 <class>servlet</class>
 <name>/ConsumerDirect/include/styles/style1/CachedFooterDisplay.jsp</name>
 <name>/ConsumerDirect/include/styles/style2/CachedFooterDisplay.jsp</name>
 <property name="do-not-consume">true</property>
 <property name="save-attributes">false</property>
 <cache-id>
  <component id="storeId" type="parameter">
   <required>true</required>
  </component>
  <component id="DC_userType" type="attribute">
   <required>false</required>
   <not-value>-1002</not-value>
  </component>
  <component id="DC_lang" type="attribute">
   <required>true</required>
  </component>
 </cache-id>
</cache-entry>

4. Verify that the fragments are now cached separately.

a. Select the Cache Policies page in Cache Monitor and verify all the modified fragments are listed in the cache policies.

b. Clear the cache using Cache Monitor's main page.

c. Resubmit the request for TopCategoriesDisplay home page.

d. Navigate to the Cache Contents page in Cache Monitor. Verify the fragments you modified are now cached separately and not consumed any longer.

You will see the following templates cached with their Cache IDs:

/webapp/wcs/stores/ConsumerDirect/include/MiniShopCartDisplay.jsp

/webapp/wcs/stores/ConsumerDirect/include/styles/style1/CachedFooterDisplay.jsp

/webapp/wcs/stores/ConsumerDirect/include/styles/style1/CachedHeaderDisplay.jsp

/webapp/wcs/stores/com.ibm.commerce.struts.ECActionServlet.class

+

Search Tips   |   Advanced Search