私は次の設定を持っています:
varnish (80) <-> nginx (8080) <-> php-fpm (9000)
(mod_php で Apache を使用した場合と同じ動作) 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 がオンになっていapp/config/config.yml
ます。symfony で次のルートを構成しました。
/esiouter
s-maxage 60 を/esiinner
使用し、esi-include for (「プレーンな」esi-tag または twig-render 関数を使用{'standalone': true}
):<esi:include src="/esiinner" />
/esiinner
s-maxage 10 を使用 (esi-include で取得)
symfonyで AppCache を有効にするとweb/app.php
、ESI タグが評価されるため、ワニスはそれらを取得せず、Content-Length
ヘッダーがあり、コンテンツはチャンクされません。AppCache を無効にすると、ワニスは ESI タグを評価し、コンテンツをチャンクして送信し、Content-Length
ヘッダーはありません。
Varnish がチャンクされた応答を送信し、esi ブロックをバッファリングせず、ページ全体を送信しないのはなぜですか? ESI を使用して Symfony アプリケーションの前で Varnish を使用している場合、Symfony の AppCache を使用する必要がありますか?