I am caching the product details page on Varnish, and then I purge the cache from the backend server whenever the product is updated. I want my clients to never cache this page on their side, but always ask from Varnish, so that I can serve them the most recent copy.
Currently, I have the below config for vcl_backend_response:
sub vcl_backend_response {
unset beresp.http.Set-Cookie;
#unset beresp.http.Cache-Control;
#set beresp.http.Cache-Control = "no-cache";
if (bereq.url ~ "^/products/\d+/details") {
set beresp.ttl = 1h;
}
}
But, using this config, client caches the response for 1 hour, and does not ask again, even the cache is purged on Varnish.
If I uncomment the cache-control related lines, this time Varnish does not cache the page and always asks for a fresh copy from the backend server.
Is this achievable in Varnish v6.0?