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

Cache management in eZ Publish

Sunday 22 May 2011 6:55:17 am

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

By : Matthieu Sévère

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.

Blog Post Discussion

Cache management in eZ Publish

eZ debug

Timing: Jan 18 2025 00:06:04
Script start
Timing: Jan 18 2025 00:06:04
Module start 'content'
Timing: Jan 18 2025 00:06:04
Module end 'content'
Timing: Jan 18 2025 00:06:04
Script end

Main resources:

Total runtime0.1318 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 587.7266180.8438
Module start 'content' 0.00660.0043 768.570399.1797
Module end 'content' 0.01090.1208 867.7500527.9297
Script end 0.1318  1,395.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.6254200.0002
Check MTime0.00131.0207200.0001
Mysql Total
Database connection0.00060.448310.0006
Mysqli_queries0.090168.35901410.0006
Looping result0.00110.85611390.0000
Template Total0.120591.410.1205
Template load0.00070.566610.0007
Template processing0.119890.838110.1198
Override
Cache load0.00050.346010.0005
Sytem overhead
Fetch class attribute can translate value0.00131.012810.0013
XML
Image XML parsing0.00030.239610.0003
General
dbfile0.00201.5050200.0001
String conversion0.00000.004530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs