Varnish Caching ESI Fragment
Dami Onajole
dami.onajole at largeblue.com
Mon Aug 15 15:34:27 CEST 2011
Hi All,
I am having problem using ESI with Varnish 3.0 successfully. I have an ESI
fragment that displays a notice for logged in users, included via an ESI
tag. However, varnish caches the included ESI fragment, so changes made to
the fragment, either manually, or as a result of a session does not reflect
in the including (and cached) web page.
ESI tag as used:
<esi:inlcude src="path/to/fragment.esi">
VCL configuration:
sub vcl_recv {
if (req.url ~ "[A-Za-z0-9_-]*.esi$") {
return (pass);
}
if (req.http.cookie) {
set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?",
"");
if (req.http.cookie ~ "^ *$") {
remove req.http.cookie;
}
}
remove req.http.cookie;
remove req.http.etag;
}
sub vcl_fetch {
remove beresp.http.Set-Cookie;
remove beresp.http.ETag;
#do esi processing
set beresp.do_esi = true;
if (bereq.url ~ "[A-Za-z0-9_-]*.esi$") {
set beresp.ttl = 0s;
} else {
set beresp.ttl = 24h;
}
}
My assumptions are:
1) Varnish will make requests to "path/to/fragment.esi" and the re-assemble
cache web page every time it fetches from its cache store, especially since
beresp.ttl is set to 0s for every .esi fragments
2) Varnish does not store the ESI fragments together with a web page in its
cache store
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110815/8e8d3fc5/attachment-0002.html>
More information about the varnish-misc
mailing list