I have the following config:
varnish (80) <-> nginx (8080) <-> php-fpm (9000)
(Same behavior using Apache with mod_php) My Varnish config:
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
sub vcl_recv {
set req.http.Surrogate-Capability = "abc=ESI/1.0";
}
sub vcl_fetch {
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
unset beresp.http.Surrogate-Control;
set beresp.do_esi = true;
}
}
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Varnish-Cache = "HIT Varnish (" +obj.hits+ ")";
} else {
set resp.http.X-Varnish-Cache = "MISS";
}
}
ESI is turned on in the app/config/config.yml
. I configured the following routes in symfony:
/esiouter
with s-maxage 60 and having an esi-include for/esiinner
(using "plain" esi-tag or twig-render function with{'standalone': true}
):<esi:include src="/esiinner" />
/esiinner
with s-maxage 10 (fetched by esi-include)
Now when I enable the AppCache in web/app.php
symfony evaluates the ESI tags so varnish doesn't get them and we have a Content-Length
header and the content is not chunked. If I disable the AppCache, varnish evaluates the ESI tags and sends the content chunked and there is no Content-Length
header.
Why is Varnish sending a chunked response and is not buffering the esi-blocks and sending the page as a whole? If I am using Varnish infront of my Symfony-Application with ESI, do I have to use Symfonys AppCache?