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.
- Backend sends cache control :Cache-Control: no-cache, no-store, must-revalidate
- Varnish should cache the response.
- Browser should not cache the contents so in response from varnish to -browser 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 used.
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";
if (beresp.status >= 400 && beresp.status <= 599) {
set beresp.ttl = 0s;
}
}
}
Any help is highly appreciated.
Best Answer
Sure, use vcl_deliver in your .vcl config file: