<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 20, 2016 at 4:38 PM, Pinakee BIswas <span dir="ltr"><<a href="mailto:pinakee@waltzz.com" target="_blank">pinakee@waltzz.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
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:<br>
<br>
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.<br>
<br>
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.<br></blockquote><div><br></div><div>Two tips. One is the cookie VMOD, which helps when dealing with cookies. If you don't wanna use it you can also look at the example here: <a href="https://www.varnish-cache.org/docs/4.1/users-guide/increasing-your-hitrate.html#cookies">https://www.varnish-cache.org/docs/4.1/users-guide/increasing-your-hitrate.html#cookies</a> - it will at least point you in the right direction.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I tried implementing the above logic in vcl_recv and vcl_backend_response with my limited knowledge, but varnish started serving blank pages.<br></blockquote><div><br></div><div>That sounds like a backend bug.</div><div><br></div></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><table border="0" cellpadding="0" cellspacing="0" style="border-bottom-width:1px;padding-top:5px;border-top-style:solid;width:550px;padding-bottom:5px;border-bottom-color:rgb(238,238,238);border-top-width:1px;border-bottom-style:solid;line-height:1.5em;border-top-color:rgb(238,238,238);color:rgb(102,102,102);font-size:12px;font-family:'Helvetica Neue',Arial,sans-serif;margin-top:20px"><tbody><tr><td width="100"><img src="http://www.varnish-software.com/static/media/logo-email.png"></td><td><font color="#222222"><span style="font-size:14px"><b>Per Buer</b></span></font><br>CTO | Varnish Software AS<br>Cell: <a value="+4790181750" style="color:rgb(17,85,204)">+47 95839117</a><br><span style="font-weight:bold">We Make Websites Fly!<br><a href="https://www.varnish-software.com/" style="color:rgb(17,85,204)" target="_blank">www.varnish-software.com</a></span></td></tr></tbody></table><br><div style="color:rgb(136,136,136)"><a href="http://info.varnish-software.com/signature" target="_blank"><img src="http://files.varnish-software.com/signature.png"></a><br></div></div></div></div></div>
</div></div>