Configuring Varnish for Caching based on Cookies

Pinakee BIswas pinakee at waltzz.com
Fri May 20 16:38:45 CEST 2016


Hi,

I am a beginner with Varnish and planning to deploy it for our ecommerce 
live platform. I am trying to learn Varnish and VCL and having trouble 
for our specific scenario:

I would like to cache pages when a user is not logged in - and this is 
determined by a cookie (which is standard). The ecommerce platform is 
based on python Django - and there are bunch of other cookies which are 
not relevant for caching but they can't be unset/removed as they are 
needed by the origin/backend server.

Hence, the solution would be to check if the login cookie is present or 
not. If login cookie not present, cache the page and fetch from cache 
else pass it to the backend.
I tried implementing the above logic in vcl_recv and 
vcl_backend_response with my limited knowledge, but varnish started 
serving blank pages.

Would really appreciate if you could please guide me with the above.

Also, if you could provide some good simple documentations to start with 
(I am going through the Varnish software book), would be go great help.

Thanks,
Pinakee



More information about the varnish-misc mailing list