Set cache headers for browsers by varnish.
sreeranj s
sreeranj4droid at gmail.com
Tue May 9 12:48:05 CEST 2017
Hi,
Is it possible for varnish to send the "Cache-Control: no-cache, no-store,
must-revalidate" cache control response to browser, while varnish caches
the response.
Scenario is like this.
1) Backend sends cache control :Cache-Control: no-cache, no-store,
must-revalidate
2) Varnish should cache the response.
3) Browser should not cache the contents so in response from varnish it
should show
cache control :Cache-Control: no-cache, no-store, must-revalidate
I have tried using Cache-Control: no-cache, no-store, must-revalidate in
set beresp.http.Cache-Control, but this causes varnish not to cache the
responses.
Given below is the vcl_backend_response
=============================
sub vcl_backend_response {
if (bereq.url == "/") {
unset beresp.http.expires;
unset beresp.http.set-cookie;
set beresp.ttl = 3600s;
set beresp.http.Cache-Control = "max-age=0";
#Prevent caching of 404 and 500 errors
if (beresp.status >= 400 && beresp.status <= 599) {
set beresp.ttl = 0s;
}
}
}
=============================
Any help is highly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20170509/4127c7bd/attachment.html>
More information about the varnish-misc
mailing list