Commerce Composer widget caching and invalidation

Site and store-level widgets can be cached for improved store performance. Widgets are cached in one of two ways:

Every widget has an entry in cachespec.xml. It is within this file where caching parameters are set. Not all widgets are cached, however. Whether a widget is cached, and how it is cached depends primarily on its function:

Widget content Widget examples Required cachespec.xml entries Reasoning
Always dynamic Inventory Availability widget

Discounts widget

The do-not-cache and do-not-consume properties are set to true These widgets are not cached because their content is generated in real-time based on interactions with the shopper. The content is always changing, and is never the same across different shoppers.
Sometimes dynamic Content Recommendation widget

Category Recommendation widget
e-Marketing Spot widget

The do-not-cache and do-not-consume properties are set to true.

The following metaDataGenerator is added:

    <metadatagenerator>
    com.ibm.commerce.marketing.cache.EMarketingSpotMetaDataGenerator
    </metadatagenerator>

Marketing widgets can contain static content, or dynamic content that is personalized for different shoppers. Therefore, they can be consumed or cached independently based on their individual behavior.

While the do-not-cache and do-not-consume properties are required to be set to true, they can be ignored. The included metadata generator decides whether to cache the marketing widgets or not based on if the content is determined to be static or dynamic.

For more information, see Overview of e-Marketing Spot JSP caching based on activity behavior.

Static / consumable Heading widget

Short description widget

The do-not-cache and do-not-consume properties are set to true.

The following special dependency ID is added:

    <dependency-id>ignoreDoNotConsume</dependency-id>

Widgets with static content can be consumed by their parent pages. When a widget is consumed, the widgets dependency IDs must be added to the parent page cache entry. These dependency IDs cause the cached parent page to be invalidated whenever the widget contents are modified.For this process to be achieved, any consumable widget must contain a special tag within its JSP:

    <wcpgl:pageLayoutWidgetCache/>

When the widget JSP executes, the associated tag handler class checks for the presence of the ignoreDoNotConsume dependency ID. If present, the do-not-consume attribute is reset to false, enabling the widget to be consumed by the parent page. It also adds this widget dependency ID values to that of the parent page.

Here is a sample cache entry for the static heading widget. Refer to cachespec.xml for more details and examples.


Related concepts
Widgets for Commerce Composer
Commerce Composer widget library
Improving store performance through Commerce Composer JSP caching
Commerce Composer layout caching and invalidation
Developing Commerce Composer assets


Related tasks
Creating Commerce Composer widgets