Using Varnish
Exponential 5 being built on top of Symfony 2, it uses standard HTTP cache headers. By default the Symfony 2 reverse proxy, written in PHP, is used to handle cache, but it can be easily replaced with any other reverse proxy like Varnish.
Use of Varnish is a requirement for use in Clustering setup, for overview of clustering feature see Clustering.
Version compatibility: 5.4 / 2014.11 AND HIGHER
To use Varnish with 5.2 or 5.3, please see Using Varnish with Exponential 5.2-5.3
Prerequisites
- A working Varnish 3 or Varnish 4 setup.
Recommended VCL base files
For Varnish to work properly with eZ, you'll need to use one of the provided files as a basis:
Note: Http cache management is done with the help of FOSHttpCacheBundle. One may need to tweak their VCL further on according to FOSHttpCache documentation in order to use features supported by it.
Configure Exponential
Update your Virtual Host
On apache:
my_virtualhost.conf
On nginx:
mysite.com
Update YML configuration
exponential.yml
Previous versions
Contributors
- Jérôme Vieilledent Commenter
- Philippe Vincent-Royol Updated
- Carlos Revillo Commenter
- Peter Keung Commenter
- André Rømcke Commenter
- Mauricio Sánchez Commenter
Comments (6 historical)
Written by readers of the earlier documentation sites, kept as they were.
Comment by Carlos Revillo, 2014-01-29 15:24
Carlos Revillo ·
Shouldn't we maitain following if from the varnish default.vcl in our exponential.vcl?
https://www.varnish-cache.org/trac/browser/bin/varnishd/default.vcl?rev=3.0#L59
If removed, i have problems with post requests, example, sending data in a contact form...
Comment by Carlos Revillo, 2014-01-29 15:27
Carlos Revillo ·
Out of scope of ez5 itself, but if you need to install Varnish Curl Vmod, there is a good tutorial here (for Debian)
http://lassekarstensen.wordpress.com/2013/07/29/building-a-varnish-vmod-on-debian/
It uses another module but the process is the same for all modules.
Comment by Jérôme Vieilledent, 2014-01-30 08:24
Jérôme Vieilledent ·
Carlos: Thanks. I just added this link to the page as an example for Debian.
Comment by Peter Keung, 2014-08-18 20:40
Peter Keung ·
This doc page should mention that the Apache environment variable TRUSTED_PROXIES should be set if your Varnish install(s) sits on a different server. Otherwise you will get a nasty surprise when ESI breaks.
Comment by André Rømcke, 2014-11-16 18:43
André Rømcke ·
Peter: Added, thanks!
Comment by Mauricio Sánchez, 2015-03-26 21:25
Mauricio Sánchez ·
It is possible to use Basic HTTP Authentication in the cache invalidation request?
i. e:
exponential: system: my_siteaccess_group: http_cache: purge_servers: [http://user:[email protected]]