Hands-on


HTTP Caching with Varnish


Bulgaria PHP Conference, September 25th, 2015


© David Buchmann

Step 1

apt-get install varnish
            

Step 1

apt-get install varnish
            

Step 2

service apache2 restart
service varnish restart
            

Step 3

What could possibly go wrong?

httpstatusdogs.com

Overview




HTTP Refresher

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

twitter.com/stevelosh/status/372740571749572610

Tools and helpers

                wget -Sq --spider varnish.lo/solutions/expiration.php
                curl -o /dev/null -sD - varnish.lo/solutions/expiration.php
            



HTTP Cache Control

Cache control headers

HTTP 1.1, RFC 2616, Sections 13.2 and 13.3

Cache Expiration

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 (HTTP 1.0 - avoid!)
  4. Default to default_ttl if nothing specified