Issue with passing Cache-Control: no-cache header to Tomcat during cache misses

Uday Kumar uday.polu at indiamart.com
Mon Jun 12 20:30:34 UTC 2023


Hello,

When a user refreshes(F5) or performs a hard refresh(ctrl+F5) in their
browser, the browser includes the *Cache-Control: no-cache* header in the
request.
However, in our* production Varnish setup*, we have implemented a check
that treats* requests with Cache-Control: no-cache as cache misses*,
meaning it bypasses the cache and goes directly to the backend server
(Tomcat) to fetch the content.

*Example:*
in vcl_recv subroutine of default.vcl:

sub vcl_recv{
      #other Code
      # Serve fresh data from backend while F5 and CTRL+F5 from user
        if (req.http.Cache-Control ~ "(no-cache|max-age=0)") {
                set req.hash_always_miss = true;
        }
       #other Code
}


However, we've noticed that the *Cache-Control: no-cache header is not
being passed* to Tomcat even when there is a cache miss.
We're unsure why this is happening and would appreciate your assistance in
understanding the cause.

*Expected Functionality:*
If the request contains *Cache-Control: no-cache header then it should be
passed to Tomcat* at Backend.

Thanks & Regards
Uday Kumar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20230613/8148d787/attachment.html>


More information about the varnish-misc mailing list