Manage a custom servlet cache instance: configuration and invalidation

Most of the times in your baseCache instance falls several different types of cache entries: full pages, fragments, marketing command objects, policies.

Based on the “Best practices for caching design and decisions“, those entries could be moved to a different (or differents) servlet cache instances placed “in the default traditional DynaCache provider for the WebSphere Application Server provider or the WebSphere eXtreme Scale DynaCache provider”.

In general depending on the invalidation volume, you can evaluate moving the most frequent invalidated cache entries to a different instance (an high invalidation rate is not good for WXS) and create a replication domain to associate it.

But how to create a new servlet cache instance and use it in Websphere Commerce?

First you have to create a new servlet cache instance through WAS console

Custom Servlet Cache Instance

and follow the Knowledge center indications about his configuration adding all needed custom properties.

Restarting the server, these message on sysout will tell you the new servlet cache instance is up and running

CacheServiceI I   DYNA0015I: Dynamic Servlet Caching encountered an error: Error type=config warning. cacheName=services/cache/AuroraESpots CacheConfig.disableTemplateInvalidation=true. Template invalidations are disabled for JSP reload.
ResourceMgrIm I   WSVR0049I: Binding AuroraESpots as services/cache/AuroraESpots
ServerCache   I   DYNA1001I: WebSphere Dynamic Cache instance named services/cache/AuroraESpots initialized successfully.

Now services/cache/AuroraESpots instance has to be configured on cachespec.xml

On this sample we will move espot JSP snippets from baseCache to the new services/cache/AuroraESpots cache instance.

This is quite simple: all marketing cache entries has to be placed into this tag

<cache-instance name=”services/cache/AuroraESpots”>


I copied marketing cache entries from the sample cachespec.xml file in WCDE_installdir\components\foundation\samples\dynacache\marketing\cachespec.xml

To check this cache configuration we will simply load Aurora home page.

This page view will generate a cache entry for every espot in the page.

This is not the OOB behavior: I added a cache entry for JSP snippet caching based on activity behavior on



and I changed ContentRecommendation.jsp as explained on Knowledge Center.

With this configuration, loading Aurora home page

Aurora Home Page espots

9 cache entries are created

Espot cache entries

All those entries are associated to the JSP snippet caching

Espot cache entries detail

as you can see opening one of the entries

Espot JSP snipping detail cache

One thing to specify: the 9 espots are cached with specific cache entries because there is no cache entry for TopCategoriesDisplay in the sample cachespec.xml file I used in this post.

[Setting up JSP snippet caching based on activity behavior]

“Optional: Some optional parameters for an e-Marketing Spot can be configured as follows:
If the e-Marketing Spot JSP is included in a servlet cached page, then a static e-Marketing Spot has the JSP consumed by the parent page. If you want to always cache the e-Marketing Spot JSP separately, then define a cacheWithParent parameter with a value of false.”

And now the second part: invalidate the generated cache entries in our custom servlet cache instance.

First of all you need to apply an APAR if Commerce FixPack 7 is not installed (or request a build for your environment)


Then you have to add a special cache entry in your cachespec.xml

<component type=”method” id=”getString”>

This will allow to DynacacheInvalidation job to identify the custom servlet cache instance and send them the correspondent invalidations inserting a specific string (“cmd:”) in TEMPLATE column on CACHEIVL table.

“If the scheduler job locates a value in the TEMPLATE column that starts with cmd: prefix for a new row, the job uses the rest of the value that follows the prefix as a Java class name…”

To understand the whole process we are invalidating the JSP snippet corresponding to the HomeLeft_Content espot (the image with Shirt Sale 15% off men’s dress shirts)

DependencyIds espot home page

Webactivity associated to espot

The EMarketingSpotMetaDataGenerator associated to this entry generates 4 dependencyIds: emsId:10752,contentId:10156,contentId:10157 and contentId:10158.

We can invalidate that content using one of them: let’s use the emsId.

To invalidate that content we will use DynacacheInvalidation scheduled job inserting a specific record con CACHEIVL table

INSERT INTO cacheivl (template, dataid, inserttime) values (‘’, ’emsId:10752′, CURRENT TIMESTAMP);

As explained in Knowledge center (it could be explained better ;-)), we have to use the pattern “cmd:”+java class on TEMPLATE column and then indicate on DATAID column the dependencyId to invalidate.

After waiting for DynacacheInvalidation execution, the cache entries on our custom servlet are 8 now

Cache entries after invalidation

Websphere Commerce and Portal Architect ✔ Motivated IT professional with more than ten years of experience, combining Java and JEE developer skills with systems and IBM products installation knowledge. ✔ Strong experience and skills on planning, architecting and implementing complex commerce and portal solutions based on IBM middleware products. ✔ Reliable with a strong network attitude, experience on leading developer's teams and manage international relationships. Specialties ✔ Pleasant manner, reliable. ✔ Ability to consider issues from different point of views. ✔ End-oriented work capacity and problem-solving attitude. ✔ Ability to work with deadlines and under pressure. ✔ Ability to prioritise tasks and manage people. ✔ Ability to increase the whole team skills. ✔ Ability to generate commercial leads

Tagged with: , ,
Posted in cache, websphere application server, websphere commerce

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: