Blog» Persistence caching with memcache in eZ Publish 5.x and eZ Platform

Persistence caching with memcache in eZ Publish 5.x and eZ Platform

By Peter Keung  | November 10, 2016  |  eZ Publish development tips, Site performance

In eZ Publish 5.x and eZ Platform, the concept of "view cache" has changed. The "module result" part of it (which was basically page-level caching if we didn't count the pagelayout) has been offloaded to HTTP caching, most often implemented with Varnish. In addition, Cache blocks no longer exist and have been replaced by ESI (Edge Side Includes) blocks.

The persistence caching element -- that is, caching of your actual content from the database -- of the "view cache" still exists, handled by default on the file system through the Stash bundle. Stash also supports memcache (which, as its name suggests, uses memory, and has a much better performance). We use memcache(d) for all of our production sites.

How to use memcache in eZ Publish

Installing memcache or memcached is straightforward. The reference documentation is good, and you can often use the default settings. As an example, on Ubuntu 14 this command is likely all you need:

sudo apt-get install php5-memcached memcached


On the eZ Publish side, this is the default configuration, which you usually end up placing in environment-specific configurations in ezpublish/config/ezpublish_<env>.yml such as ezpublish_prod.yml:

                # When using multiple webservers, you must use Memcache or Redis
                - Memcache
            inMemory: true
            registerDoctrineAdapter: false
                prefix_key: yoursite_
                retry_timeout: 1
                        port: 11211

You can add multiple servers to have a memcache pool. If you have a cluster setup, you can simply install memcache on each front-end server. See the eZ documentation for more information. If each front-end server has the same configuration files, use internal network IPs in the configuration instead of using (since every server's pointer for is to itself and thus technically different!)

Also, make sure there is no Stash configuration remaining in the default ezpublish/config/ezpublish.yml file. This could trip you up by overriding your environment-specific settings!

Bonus note: If you have front-end sessions in a cluster, you should also use memcache to store sessions. Use a second memcache pool, however, to minimize the risk that sessions get bumped out of memory by non-session data from eZ's persistence caching.

Is memcache working?

You'll know pretty quickly if persistence caching is not working because you'll make content changes that won't be reflected properly on your website. Here are some tips to get started and make sure the persistence caching is working fine:

  • Check that you can connect to the default memcache port on the server: telnet localhost 11211
  • Then, run the stats command, which will show you basic information such as cache hits and misses. When you reload a page on your website, see that these numbers change.
  • Empty your ezpublish/cache folder and then check that it is no longer growing with each page load beyond a few megabytes total (or more, depending on the size of your site): du -hs ezpublish/cache. There should still be files there, because some system components still use file caching such as for compiled template caching.
  • In non-prod environments you can check your compiled YML settings by running this command:
    php ezpublish/console debug:config ezpublish
    ... with the optional parameter --env=<environment> such as --env=stage
    (We're still on the hunt for a production "settings check" feature similar to how we can use Setup > Ini settings for legacy settings in the Administration Interface.)

Happy caching!

Join our mailing list for news, events, tips, and tools

Related Blog Posts

Built-in Varnish Cache "purge-on-publish" support in eZ Publish

eZ Publish 5 comes with built-in Varnish Cache support. Essentially this means that when content is published in the eZ Publish back-end, it notifies Varnish...

Read more »

Varnish caching of non-sensitive content for logged-in users

Varnish is great for high traffic sites where the same pages are served over and over to millions of visitors, but when you have to do something differently...

Read more »

Mugo Image Server for eZ Publish: a scalable, flexible solution

In order to increase the image serving performance of high-traffic websites and improve the editorial user interface around image management, Mugo Web...

Read more »

Site performance optimizations: a look back at Election 2012

4 years ago, in 2008, we first met what is now one of our longest ongoing clients, Rasmussen Reports. There was some stress and urgency to their problem,...

Read more »


blog comments powered by Disqus

Hi, we're Mugo Web - Nice to meet you!

We're a group of web experts who solve complex web problems.

Learn more about us »



Yes - we can do that.

Many years of experience with complex websites allows us to offer total solutions.

Learn more about what we can do »

We love our clients (and they love us too)

We've solved problems across North America and around the world.

Learn more about what we've done »

We tweet too

Follow us on Twitter for the latest Mugo happenings

mugo twitter page @mugo

© 2008 - 2018 Mugo Web. All rights reserved.