Varnish Caching Proxy


And the FOSHttpCacheBundle


Webmardi Fribourg, June 3rd 2014
© David Buchmann, Liip AG

Step 1

apt-get update
apt-get install varnish
            

Step 1

apt-get update
apt-get install varnish
            

Step 2

service apache2 restart
service varnish restart
            

Step 3

What could possibly go wrong?

What is a reverse proxy again?

HTTP is simple

GET /path

HTTP/1.1 200 OK
Content-Type: text/html

<html>...</html>
            

HTTP verbs

HTTP response codes

https://twitter.com/stevelosh/status/372740571749572610

Default Varnish behaviour

http://httpstatusdogs.com

Cache control headers

Cache-Control: s-maxage=3600, max-age=900
Expires: Thu, 15 May 2014 08:00:00 GMT
            
  1. s-maxage
  2. max-age
  3. Expires

Do not cache

Cache-Control: s-maxage=0, private, no-cache
            

Keep variants apart

Vary: Accept, Cookie
            

Cache validation (I)

Last-Modified: Tue, 13 May 2014 08:13:20 GMT
            
If-Modified-Since: Tue, 13 May 2014 08:13:20 GMT

304 Not Modified