WebSphere Commerce Search caching
WebSphere Commerce Search uses fragment caching in the storefront. Notes:
- Search results from the search results page are not cached unless a category ID is associated with them. That is, search results with facets or search terms are not cached.
For a fragment to be cacheable, it must be self-executable. Each dynamically included JSP file must contain its own <cache-entry> defined in the cachespec.xml file. This <cache-entry> is required to have the JSP file served up by the dynamic cache when it receives a request. Otherwise, each dynamically included JSP file is re-executed for each request. For example, if StoreCatalogDisplay.jsp dynamically includes CachedHeaderDisplay.jsp, CachedFooterDisplay.jsp and CachedStoreCatalogDisplay.jsp and you only set up a <cache-entry> for the CachedStoreCatalogDisplay.jsp. Then, when you request the StoreCatalogDisplay page, the CachedStoreCatalogDisplay.jsp, CachedHeaderDisplay.jsp, and CachedFooterDisplay.jsp files are executed if they are not cached.
Catalog filter caching
If the site uses catalog filters, ensure that catalog filter caching is enabled.
Cache invalidation
When the search index is updated, the search related cache entries must be invalidated using the Dynacache API. WebSphere Application Server dynamic caching provides the following APIs to support programmatic invalidation:
- com.ibm.websphere.cache.invalidateById
- com.ibm.websphere.cache.invalidateByTemplate
- com.ibm.websphere.cache.clear
WebSphere Commerce also provides a DynaCacheInvalidation command, which is called by the scheduler periodically to process the records in the CACHEIVL table. It then calls the WebSphere Application Server dynamic cache invalidation APIs to invalidate the specified cache entries. By default, the schedule interval is every 10 minutes. For more information about this invalidation process, seeCache invalidation.
Caching considerations for WebSphere Commerce Search
We can use fragment caching for WebSphere Commerce Search results. However, we must practice caution to ensure that your caching strategy performs well. At a minimum, we must test your caching strategies before publishing the store to production.
In addition to using DynaCache in the WebSphere Commerce server and caching some of the relatively static search data, such as auto-suggested search entries, we can use the WebSphere Commerce search server to cache index data in memory. The size of the index cache pools must be configured based on the memory heap size that is allocated for the search server.
- WebSphere Commerce Search data cache
The WebSphere Commerce Search server code uses the WebSphere Dynamic Cache facility to perform caching of database query results. Similar to the data cache used by the main WebSphere Commerce server, this caching code is referred to as the WebSphere Commerce search server data cache.- Enable the WebSphere Commerce Search data cache
The search server data cache uses DistributedMap object caches, which are defined automatically during feature pack installation.