Set cache headers for browsers by varnish.

Guillaume Quintard guillaume at varnish-software.com
Tue May 9 15:07:21 CEST 2017


Easy fix is: set it in vcl_deliver instead of vcl_backend_response.

Have a look at builtin.vcl (varnishadm vcl.show -v boot) that gets
automatically appended to your vcl. If you wish to bypass it,
return(deliver) from your code and the built-in code won't be ran.

-- 
Guillaume Quintard

On May 9, 2017 14:00, "sreeranj s" <sreeranj4droid at gmail.com> wrote:

> 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.
>
>
>
>
>
>
> _______________________________________________
> 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/20170509/81da3edb/attachment.html>


More information about the varnish-misc mailing list