How do I use the Varnish HTTP accelerator with eZ Publish
Table of contents
By default webpages are delivered by the Apache Webserver. Instead of using Apache you can also use the Varnish HTTP accelerator infront of Apache.
To make this happen please proceed wiht the following steps.
Step 1
Configure eZ Publish so that is sends out proper cache headers.
Please edit settings/override/site.ini.append.php
[HTTPHeaderSettings] CustomHeader=enabled OnlyForAnonymous=enabled HeaderList[] HeaderList[]=Pragma HeaderList[]=Cache-Control Cache-Control[] Cache-Control[/]=public, must-revalidate, max-age=10800 Cache-Control[/rss]=public, must-revalidate, max-age=10800 Cache-Control[/content/pdf]=public, must-revalidate, max-age=10800 Pragma[/]= Pragma[/rss]= Pragma[/content/pdf]= Expires[] Expires[/]=+600 Expires[/rss]=+600 Expires[/content/pdf]=+600
Step 2
Prove that it works. To see if your setup was successfull take a look in your HTTP header of eZ Publish website.
If your header deliver a HIT. Varnish works properly. The number after the hit shows how often the item has been delivered.
X-Cache: 82.0.0.0:HIT:1
If your header deliver a MISS. Varnish works properly, but it hasn`t cached the request.
X-Cache: 82.0.0.0:MISS
Disable Varnish
If you need to temporarly disable Varnish you can add this line to your .htaccess. Other wise varnish will listen to your HTTP cache header which will tell Varnish to cache the item or not.
Header add X-Varnish-Control "disabled"
Purge cache for your domain
bash-3.2$ telnet 127.0.0.1 80 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. PURGE / HTTP/1.1 Host: example.com
And hit two times enter!
