Search in the Documentation:

Caches

Front-end caches in Jahia 6.5 are implemented as a rendering filter and use the EHCache library (http://ehcache.org/) as the backend cache implementation.

The default filter implantation that does the cache aggregation is called AggregateCacheFilter.

This filter caches each individual module output separately and then aggregates all cache fragments at rendering time to deliver the full page to the client.

It means that

  • A particular module output can be “un-cached” without deactivating cache on the whole page
  • When a cache fragment is outdated only a minimal portion of the page has to be recalculated

Cache Work both by expiration and invalidation

Usage of cache keys maximize sharing of elements by finely computing the key associated with an element based on roles (basically, users sharing the same roles will share the same cache fragments).

The cache, thanks to the granular rendering model, manages dependencies and invalidations transparently.

  • If an object is modified its corresponding cache fragment is invalidated
  • The fragment will be processed again as soon as it is necessary for a user
  • If necessary, parent or children fragments will also be transparently invalidated

Sometimes objects stored in the JCR are not technically related one to each other, but the invalidation of one object could request an invalidation of another one (for example because of a functional requirement). Typically, a content gathering zone (SQL-2 query for example) can in no way know whether gathered objects have been modified or not. The component only displays the query result and this result is put in cache once generated. In such cases, dependencies may be entered manually. The establishment of a strong dependency forces invalidation. Without this dependency, the output of the query object is cached until expiration (default expiration =4h).

The tag <template:addCacheDependency/> adds a cache dependency on the rendering associated with a type, on a node or a regular statement referencing node paths. If the dependency is modified, the cache of the current node is flushed.

To add a dependency on a node, you can use different attribute, such as :

node = dependant node

<template:addCacheDependency node="${comments}"/>


path = path of the dependent node

<template:addCacheDependency path="${currentNode.path}/comments"/>


uuid = uuid of the dependent node

It is also possible to use regexps to set dependencies on a path:

flushOnPathMatchingRegexp= regular statement representing the nodes on which to apply the dependency.

<template:addCacheDependency flushOnPathMatchingRegexp="${renderContext.mainResource.node.path}/.*/comments"/>


For more examples, we recommend that you look at the built-in Jahia templates that will illustrate how to use cache dependencies to provide an efficient yet flexible integration. Remember that proper caching is essential to high-performing web sites.

manage request parameters with caches

if you want to use parameters in cached view, you have to set the cache.requestParameters property in the property file of the view. Set wanted parameters separated by a coma, use star as a wild char

for example

cache.requestParameters=begin*,end*,pagesize*

will allow you to use all parameters starting by begin, end and pagesize within your view.