Slides for my Laracon EU 2022 presentation in Amsterdam about caching Laravel applications with Varnish.
See https://feryn.eu/speaking/taking-laravel-edge-leverage-http-caching-varnish-maximum-scalability/ for more information.
68. sub vcl_recv {
set req.http.Surrogate-Capability = "key=ESI/1.0";
}
sub vcl_backend_response {
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
unset beresp.http.Surrogate-Control;
set beresp.do_esi = true;
}
}
86. HTTP/1.1 200 OK
Host: localhost
Content-Language: en
GET / HTTP/1.1
Host: localhost
Accept-Language: en
HTTP/1.1 200 OK
Host: localhost
Content-Language: en
GET / HTTP/1.1
Host: localhost
Accept-Language: nl
88. HTTP/1.1 200 OK
Host: localhost
Content-Language: en
GET / HTTP/1.1
Host: localhost
Accept-Language: en
HTTP/1.1 200 OK
Host: localhost
Content-Language: nl
GET / HTTP/1.1
Host: localhost
Accept-Language: nl
91. sub vcl_recv {
set req.http.Surrogate-Capability = "key=ESI/1.0";
}
sub vcl_backend_response {
set beresp.ttl = 1h;
set beresp.grace = 2h;
set beresp.http.Vary = "Accept-Language,
Accept-Encoding, X-Forwarded-Proto";
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
unset beresp.http.Surrogate-Control;
set beresp.do_esi = true;
}
}