所以我的问题:我有一个大型Symfony Project 2.3,Varnish 5.因此,我想通过Symfony函数render_esi()包含一些片段。毕竟,我想了解为什么不包含任何文件,甚至简单地test.php。问题是它没有包含任何内容,而是标签esi:包括src" ..."我看不到。好的,让我们看看所有配置:
Symfony:config.yml
esi:
enabled: true
fragments:
path: /_fragments
some.html.twig:
<h2>Here must be content</h2>
{{ render_esi(url('esi_megamenuBanners')) }}
{{ render_esi(controller("OstrovWebBundle:Frontend/Page:megamenuBanners")) }}
<esi:include src="https://mo.loc/test.php">
<h2>end content</h2>
这是一种三种不同的方式,我试图发射Esi。
varnish配置:
sub vcl_recv {
#Add a Surrogate-Capability header to announce ESI support.
set req.http.Surrogate-Capability = "abc=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;
}
}
我检查了两个标题替代 和替代性能 - 它们存在。
顺便说一句,我使用nginx:https-> varnish--> nginx:http:8080-> symfony project。
我花了很多时间进行实验,但没有找到任何决定...请告诉我我的错误在哪里?
所以,这是一个答案: ESI不适用于HTTPS !我只是编写 path()函数而不是 url(),一切都很好!
(我没有找到有关HTTP和ESI的任何信息,也许我错了;所以要小心...)
第二,我不明白替代控制不需要ESI子要求,所以当配置缓存规则时,我很妄想。 surnogate-control 不在sub-requests 中使用。
我掌握的第三件事是 render_esi(url(" someurl"))和 render_esi(controller(" somebundle:somebundle:nameofcontroller:someaction:someaction:someAction"))):::首先将URL在路由之前指出;第二使用片段。因此,这对缓存规则很有帮助。