This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Learn » eZ Publish » eZ Publish Cache In Details: Template...

eZ Publish Cache In Details: Template Compilation And INI Cache

Tuesday 15 January 2013 1:02:43 pm

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

Templates compilation

To better understand the role of the « View Cache » or « Cache blocks », it is important to differentiate two concepts that are often mixed up :

  • The templates compilation, which is discussed in this chapter
  • The template cache, which in fact means caching the content of cache-blocks. The cache-block mechanism will be detailed in the next chapter


The confusion between these two caching systems comes from the different interfaces and documentations, which exploits the expression “template cache”, without specifying whether we’re talking about the compilation or the template-block cache files linked to the cache-block.

What is the purpose of the template compilation?

When the templates compilation directive is enabled, all your templates files (*.tpl) which you worked hard on are transformed (or more like “compiled”) into PHP files. Thus when a website visitor requests to display a page, it necessarily requires the execution of a number of templates (often times a few dozen of them).

  • Situation 1: These templates do not exist in their compiled version : eZ Publish will first compile templates involved (transformation of eZTemplates syntax of .tpl files into PHP syntax), then make available the compiled version (therefore in PHP) for the future construction of the view cache or of the cache blocks. We could summarize this sequence in “TPL > PHP > xHTML (or others)”
  • Situation 2: These templates are available in their compiled version : during the view cache construction, eZ Publish executes directly the PHP code without interpreting once again the template files (.tpl) using eZTemplate syntax. We could summarize this sequence in “PHP > xHTML (or others)”


This first situation (“on the fly” compiled templates) can be dramatic on a high traffic website and should never happen in an actual production website. Indeed, template compilation requires an enormous consumption of resources (both RAM and CPU, not SQL) that may create all sorts of errors if the traffic is important, and if the “stalecache” is not enabled (concept detailed below).

In all cases, it is imperative :

  • To activate templates compilation on a production site
  • To never remove the template cache massively
    • No "php bin/php/ezcache -- clear-all --purge"
    • No "php bin/php/ezcache --clear-id=templates", which does not delete template block cache but all compiled version templates
    • No "php bin/php/ezcache --clear-tag=template" which not only remove compiled cache but also template block cache
  • During an update, toforce the targeted recompilation of templates which have been modified, andonly those who have been modified (see instructions below)

Note: Compilation is enabled by default (site.ini), but often disabled during development phases or other test phases. It is therefore important to check that it is enabled when the website is pushed to production

In settings/override/site.ini.append.php / [templatesettings]:

# templates are compiled in /template/compiled/
# pre-compile templates in /template/tree, by default if TemplateCompile is enabled

Do not mix up these two parameters with the template cache activation one:

TemplateCache=enabled # put the content of cache-blocks into cache in /template-block/
36 542 Users on board!

Tutorial menu


Printer Friendly version of the full article on one page with plain styles


Proudly Developed with from