Home


5.3.1 Full-page caching and fragment caching

Full-page caching must be performed by a servlet. In the cachespec.xml, we specify that all fragments of a servlet are cached along with the servlet that includes them, using the consume-subfragments property. The cache entry for a full cached page contains:

The servlet

The content from the servlet's fragments that have no includes or forwards

Full-page caching is encouraged when many, if not all, users share the page. Good candidates in WebSphere Commerce for full-page caching are the catalog pages. Even pages containing personalized information can be cached at the this level.

Full-page caching maximizes what is contained in a given cache entry by caching the largest possible result of any request to your servers, and minimizes the time required to return the cached information on its subsequent requests. For this reason, use full-page caching whenever possible.

Sometimes full-page caching is not possible, because of user-specific fragments that need to be created for each user-page-view. Exclude those fragments from the full page cache entry using the do-not-consume property. As a result, DynaCache will achieve near full-page caching performance. The user-specific fragments are cached using separate cache entries. All of the pieces are reassembled from the cache when there is a request for the page. As the number of fragments increases, so does the time required to reassemble them.

In the event that fragment caching is not possible, you can mark a fragment as uncacheable. For example, a page is marked for full-page caching but has one or more fragments that are not cacheable. By setting the do-not-cache property to true for a fragment in the cachespec.xml, you ensure that the fragment will not be cached or consumed by its parent. This way, you can still reap the benefit of caching a page and most of its fragments.

When possible, instead of marking a fragment as uncacheable, first consider spending some time to rewrite it or create the appropriate invalidation policies in order to make it more suitable for caching.

+

Search Tips   |   Advanced Search