Advanced eZ Publish caching system

Sometimes the standard caching levels are not sufficient to satisfy the requests to the site.

If this happens, first of all we should try to fine-tune all of the single views of our application, and then use other caching tools.

Advanced settings

The CMS supports other caching directives to store other system components in faster memory. By enabling these advanced settings, we can speed up the performance of eZ Publish CMS, because these settings can optimize its behavior in complex tasks, such as choosing the template to load based on overriding rules, generating the caching for content objects, reading the translation files or the user roles, and so on.

Override cache

Override cache is the setting that enables or disables the override templates rules caching.

To enable it, set the Cache settings in the OverrideSettings section of the global (or override) site.ini file to enable.

[OverrideSettings]
...
Cache=disabled
...

Pre-generation cache

Pre-generation cache is the setting that enables or disables the possibility to cache content when the object is published, and not at the first object request.

To enable it, set the PreViewCache setting of the ContentSettings section in the global (or override) site.ini file to enable.

[ContentSettings]
...
PreViewCache=enabled
...

Translation cache

Translation cache is the setting to enable or disable the translation file caching.

To enable it, set the TranslationCache setting of the RegionalSettings section of the global (or override) site.ini file to enable.

[RegionalSettings]
...
TranslationCache=enabled
...

Role cache

Role cache is the setting that enables or disables the users' roles caching.

To enable or disable it, set EnableCaching of the RoleSettings section of the global (or override) site.ini file to true.

[RoleSettings]
...
EnableCaching=true
...

Static cache

If we realize that there are many sections in our site (nodes or trees) with a very low upgrade frequency, and that they do not have dynamic parts, in accordance with the user preferences, we can generate static cache for them through eZ Publish.

Through this feature, the static HTML files are physically generated on the file system and then they will be served using the Apache rewrite rules, rather than requesting something from the CMS caching system.

To enable the static cache feature, it needs to be set in the StaticCache settings in the ContentSettings section of the global site.ini file.

[ContentSettings]
...
StaticCache=enabled
...

Now, we need to add new rewrite rules to the .htaccess file or the virtual host apache configuration:

RewriteEngine On
RewriteCond /var/www/packtmediamagazine/static/index.html -f
RewriteRule ^$ /static/index.html [L]
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond /var/www/packtmediamagazine/static$1/index.html -f
RewriteRule ^(.*)$ /static$1/index.html [L]
RewriteRule !.(gif|css|jpg|png|jar|ico|js)$ /index.php

These rules will tell Apache to forward all of the requested objects to a static generated file, except for the images.

Subsequently, we set some settings in the global staticcache.ini.append.php file.

[CacheSettings]
HostName=packtmediamagazine
StaticStorageDir=static
MaxCacheDepth=4
# A list of url's to cache
CachedURLArray[]=/*


Here, HostName is the domain name of our website, StaticStorage is the name of the directory where static files are generated, MaxCacheDepth shows how deep you must create static files in the tree, and CachedURLArray is an array rule of the path that we have cached.

Finally, to generate static files, go to a shell of our installation of eZ Publish and run the following command:

php bin/php/makestaticcache.php -s [siteaccess_name]

Here, [siteaccess_name] is the siteaccess name involved in this operation.

Opcode cache

When we use complex software, such as eZ Publish, for an enterprise website, where performances must be the best, it's very important to install software to optimize our PHP code.

There are several optimization code applications in the market and they are all open source. Some examples are:

Several benchmarks show the APC opcode accelerator as being the best solution for use with the CMF. It is available as a module for PHP and is easily configurable.

In the next chapter, we will see how to install this module in major Linux distributions.

You can check if you have an optimizer pre-installed in your system from the control panel of eZ Publish. To do this:

  1. Log in to the site backend.
  2. Click on the Setup link in the top menu.
  3. Click on the System information link in the left-hand menu.
  4. In the PHP Accelerator section, we can see which opcode is installed.
Opcode cache

Proxy and HTTP Accelerator

You can also use reverse proxy systems for cache requests to eZ Publish. As with the opcode, there are various proxy software applications that can meet your needs. The most famous are:

Both of these are very powerful, but are also complicated to configure. To use them, we suggest contacting (or having in your team) an experienced system administrator who understands this software.

To manage the Varnish proxy, you should take a look at the open source eZ Publish extension at http://projects.ez.no/all2evcc.

To find some useful system information and gain control over granular caches, we suggest visiting the extension, http://projects.ez.no/ggsysinfo.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.202.61