WHO AM I • Alistair Stead - @alistairstead • Technical Team Lead @ Ibuildings UK • Over 12 years commercial experience developing in PHP and other technologies. • http://joind.in/3591
WHERE TO APPLY VARNISH Apply thinly over your apache cluster Client Browser Varnish Port 80 Backend Apache Port 8080 Backend Apache Port 8080 Client Browser Client Browser
sub vcl_deliver { # Set a cache header to allow us to inspect the response # headers during testing if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; set resp.http.X-Cache-Hits = obj.hits; } else { set resp.http.X-Cache = "MISS"; } }
/** * Render the html for the ESI tag * * @return string * @author Alistair Stead **/ public function getHtml() { return sprintf( '', $this->getAttributeHash() ); }
VARNISH LIMITATIONS • Prior to V3 ESI not supported with GZIP • Cookies need to be managed carefully • Still need SSL endpoint • Beware cache stampede • ESI must have a TTL greater than the parent page • Only implements a subset of ESI • Shared cache consider using s-maxage with max-age