eZ Community » Blogs » Matthieu Sévère » Cache management in eZ Publish

By

Cache management in eZ Publish

Sunday 22 May 2011 3:55:17 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

eZ Publish has a fine-grained caching system that helps achieving high performance web application. Lets review all caching levels that eZ Publish offers and important configuration.

Template compilation

Template compilation is the process of transforming a template file into a PHP file. This compilation can be quite time consuming and is triggered on demand. Thus, TemplateCompile should be enabled in site.ini, the eztc.php can help you to avoid this step by pre-compiling all templates.

View cache

This mechanism stores the generated HTML content of the current module/view. For one node one version of a cache exist for each value of the following : the view mode, the siteaccess, the user role, the pagelayout, view parameters and user preferences. Each version of a cache is stored on file system and served to the client if valid. The cache can be marked as expired when there is a new publication, then the first next call will launch the regeneration process handled by a smart mechanism called Stale Cache.

View cache is one of the key concept of eZ Publish it must be enabled and tweaked.

Depending on your case PreViewcache can be enabled to generate view cache on publish (slows down publication process).

To go further into cache expiration on publish you can dig into Smart view cache cleaning that allows to define relations between content that needs to be cleared on publication.

Cache-block

Cache-block is a template function to define blocks that will be cached in your pagelayout. Each block will store generated HTML in a file. Different version of your cache will be stored depending on the keys you give to a block.

Optimizing cache-blocks is very important as by default cache-blocks expire within 2 hours and on every content publication. Thus, depending on your block you should use ignore_content_expiry to stop expiration on content publication and expiry to define a longer expiration time (zero for no expiration). Note that subtree_expiry can be really use to define expiration on content publication restricted to a given subtree.

System cache

System cache stores system values such as roles settings, translations or settings. They are enabled by default.

HTTP Headers

eZ Publish offers complete control on HTTP headers. Thus, you can define custom cache TTL to tell the client browser to cache the page as static. Note that having control on HTTP headers can be usefull when playing with reverse proxy. 

Varnish and ESI

If eZ Publish cache optimization is not enough or you deployed eZ Publish in cluster mode, which slows down a bit, Varnish can be considered. It's a reverse proxy that integrates smoothly with eZ Publish and offers ESI support.

Varnish is able to store static pages to be delivered at high throughput later on. With the help of eZSI extension you are able to generate ESI tags with eZ Publish to define different cache block refresh within the same page.

Proudly Developed with from