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

Guillaume Quintard guillaume.quintard at gmail.com
Mon Jun 12 20:43:20 UTC 2023


Hi Uday,

Can you provide us with a log of the transaction please? You can run this
on the Varnish server:

    varnishlog -g request -q 'ReqHeader:Cache-Control'

And you should see something as soon as you send a request with that header
to Varnish. Note that we need the backend part of the transaction, so
please don't truncate the block.

Kind regards,

-- 
Guillaume Quintard


On Mon, Jun 12, 2023 at 10:33 PM Uday Kumar <uday.polu at indiamart.com> wrote:

> 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
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20230612/981768a8/attachment.html>


More information about the varnish-misc mailing list