Advanced Cache
The Advanced Cache module is collection of advanced cache strategies to help minimize load on the server, while ensuring that fresh content is served to the users. Magnolia CMS uses Ehcache, an open course Java distributed cache. All cache data is stored in the filesystem. The Ehcache filesystem can be local to the server or network, depending on the particular configuration.
Download
Enterprise clients can download the Advanced Cache module from Magnolia Store or Nexus repository
Installing
Advanced Cache is an Enterprise Edition module (3.6 and higher) included in the Enterprise Edition bundle and typically already installed. Go to Magnolia Store > Installed modules in AdminCentral to check. To install the module individually, see the general module installation instructions.
Uninstalling
- Set cache policy in
/modules/cache/config/configurations/default/cachePolicy/classback to default valueinfo.magnolia.module.cache.cachepolicy.Default. - Remove the
/modules/advanced-cachenode and its subnodes. - Shut down Magnolia, remove the Advanced Cache module JAR (
magnolia-module-advanced-cache.jar) fromWEB-INF/liband start up Magnolia again.
Strategies
Serve old content while re-caching
Using this strategy, cache is not completely cleaned on content update and entries are retained. After update, when the first request comes in, fresh cache entry generation is triggered and all further requests for the same entry are served from old cache content until the new entry is ready.
Eager re-caching
Using this strategy, cache keeps a list of the most frequently served entries. The system attempts to refresh these entries as soon as it detects an update to content. All other entries are re-cached on request. It is possible to configure the number of entries to re-cache immediately and to set the lifetime of the most served content:
- Set
/modules/cache/config/configurations/default/cachePolicy/classtoinfo.magnolia.module.advancedcache.EagerRecacheCachePolicy. - Set
/modules/cache/config/configurations/default/flushPolicy/policies/flushAll/classtoinfo.magnolia.module.advancedcache.EagerRecacheFlushPolicy
- Create a
resetAfterUpdatedata node underflushPolicy. - Set the value to
true.
- Create an
eagerRecachedata node underflushPolicy. - Set the value to the number of top most entries in the list you wish to have eagerly re-cached on every update. By default top 100 entries are eagerly re-cached.
Changing waiting time
By default Magnolia CMS waits for 10 seconds, while still serving an old version of the content, before attempting to re-cache the given entry. This timeout is controlled by the blockingTimeout property configured in the Ehcache backend. The blockingTimeout applies to the whole cache factory. If you want to change the waiting time for a particular cache policy, use the timeout property.
- Set
/modules/cache/config/configurations/default/cachePolicy/classtoinfo.magnolia.module.advancedcache.ServeUntilRecachedCachePolicy - Set
/modules/cache/config/configurations/default/flushPolicy/policies/flushAll/classtoinfo.magnolia.module.advancedcache.NotifyFlushListeningPolicy
Changes to cache policies and executors are applied immediately. Setting incorrect values can render the Magnolia instance inaccessible. If this happens, try the Groovy Rescue Servlet.