So my problem: I have a big symfony project 2.3, varnish 5. So I want to include some fragment by symfony function render_esi(). After all problem I want to understand why doesn't include any file, even simply test.php. The problem is it's not include any content, but tag esi:include src"..." I don't see. Ok, let's see all configs:
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>
Its a three different ways, which I tried to fire ESI.
Varnish config:
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;
}
}
I checked the both headers Surrogate-Control and Surrogate-Capability - they exists.
By the way, I use nginx:https -> varnish -> nginx:http:8080 -> symfony project.
I spend much time for experiments and I didn't find any decision... Please tell me where is my mistake?
So, that is an answer: ESI does not work with https! I just write path() function instead url() and everything became all right!
(I didn't find any information about https and ESI, maybe I wrong; so be carefull...)
Second I've not understood that Surrogate-Control need not for ESI sub-requests, so I was in delusion when configure my cache rules. Surrogate-Control don't use in sub-requests.
The third thing which I grasped is different between render_esi(url("someUrl")) and render_esi(controller("someBundle:nameOfController:someAction")): first make url which you point before in routing; second use fragments. So it would be helpful for cache rules.