Configuring Varnish for Caching based on Cookies

Per Buer perbu at varnish-software.com
Tue May 24 10:58:46 CEST 2016


On Tue, May 24, 2016 at 10:46 AM, Pinakee BIswas <pinakee at waltzz.com> wrote:

> I am trying to set Varnish to cache content when login cookie is not
> present. Hence, I have modified the following subroutines:
>
>
What you want to do is to modify the request so the default VCL will cache
it rather than force Varnish to cache it. If you force Varnish to cache it
Varnish will end up caching it with cookies and such. This is potentially
dangerous.

So I would recommend something like this in vcl_recv:

if (req.http.cookie !~ "logged in") {
    unset req.http.cookie; # strip the cookies - we don't need them
}

 # if there is a cookie here still the default policy will make sure the
request isn't cached.



Per.

-- 
*Per Buer*
CTO | Varnish Software AS
Cell: +47 95839117
We Make Websites Fly!
www.varnish-software.com
<http://info.varnish-software.com/signature>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160524/c41e47e8/attachment-0001.html>


More information about the varnish-misc mailing list