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

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

How compiled templates are stored?

For the braves still focused and willing to learn more, eZ Publish stores the compiled version of the templates in the directory:

{VarDir}/cache/template/compiled/
{VarDir} = value of the VarDir parameter in site.ini (or your specific override), generaly "var/mywebsite"

File names are relatively straightforward:

{templatename}-{hash}php
ex: "pagelayout-49f4458d0b68aec3cf2de63a6918fd61.php"

The hash is calculated using two different methods, depending on the parameter ShareCompiledTemplates ('TemplateSettings' section in site.ini)
Code from lib/eztemplate/classes/eztemplatecompiler.php

if($shareTemplates)
$cacheFileKey = $key . '-' . $language;
else
$cacheFileKey = $key . '-' . $internalCharset . '-' . $language . '-' . $useFullUrlText . $accessText . "-" . $pageLayoutVariable . '-' . eZSys::indexFile();
 
$cacheFileName = $extraName . md5($cacheFileKey) . '.php';
 
return $cacheFileName;

 

Table of the elements of the hash key, in ShareCompiledTemplates=disabled mode

Element of the hash key Meaning Example of value
key MD5 of the full path of the template md5(‘extension/ezwebin/design/ezwebin/templates/pagelayout.tpl’)
internalCharset Internal charset utf-8
language Language defined for the siteaccess used at the moment of compilation fre-FR
useFullUrlText According to the directive UseFullUrl (layout.ini) if the template is compiled during an URL request like “layout/set/...” (layout module) full | relative
accessText Name of the siteaccess used at the moment of compilation, preceded by
« - »
-site_admin
pageLayoutVariable Name of the personalized pagelayout, if the template is compiled during an URL request of the “layout/set/print” type for example (layout module) print_pagelayout.tpl
indexFile The root of the site index which may vary according to various parameters, such as the name of the siteaccess in “URI” mode, or the root “layout/set/... site_admin | layout/set/print
extraName The name of the template without the .tpl, ended with “- pagelayout-

So the hash key is composed of several parameters combined, which are essential to know in order to understand and control the impact of a complete removal of the compiled templated.
Indeed, a multilingual website with many siteaccess and a massive usage of the ‘layout’ module (layout/set/... which is quite discouraged to use by the way, but this is another topic) could generate a large number of possible combinations of compiled cache that will then have to be reconstruct during a large expiry!

Note: The most observant of you have noticed the presence of the directory « {VarDir}/cache/template/tree/ ». This directory contains some kind of pre-caching or “build tree”, which is only present when the NodeTreeCaching setting is enabled, and accelerates the compilation of different variants of the same template (by using PHP’s compilation tree rather than the original .tpl). During manual removal of targeted caches (rm), it may be necessary to also remove the corresponding file in the involved directory, named [hash]-[template_name].php

compiled templates diagram

Compiled Templates Diagram

 
36 542 Users on board!

Tutorial menu

Printable

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

Author(s)

Proudly Developed with from