Caching for some cookies?

Albert Tollkuçi albert.tollkuci at gmail.com
Thu Sep 1 11:57:53 CEST 2016


Hello,
I've started using Varnish a few months ago and my vcl files has started to
get complicated. I'm serving 5 different sites with the same varnish
instance (using different backends) and this part is working.

Now I have some cases that for some sites I need to keep some cookies and
cache different versions based on them. Basic scenario is to show the user
a message only the first time he sees the page. Without varnish if the
cookie is not there I set it and show the message. Next time the cookie is
there and no message is shown.

With varnish my logic is to include the cookie in hash and cache two
different versions. The challenge is to make sure cookies are set correctly
and here I'm kind of stack. I've added some debug messages in my vcl and
for some reason I'm not seeing the cookies I set in my server in
vcl_backend_response. Inside the routine, I have the following code in the
beginning:

       # AT: DEBUG
       if(bereq.http.x-at-debug == "1") {
         std.log("AT DEBUG - bereq URL: " + bereq.url + ". Cookies: '" +
bereq.http.Cookie + "'");
         std.log("AT DEBUG - beresp set-cookie: '" +
 beresp.http.set-cookie + "'");
       }

I set x-at-debug header in vcl_recv based on my IP, so I can track only my
requests. In the server side I see the cookie "__IKUB_AL_Myikub_PopUp"
being set, but in vcl_backend_response is not.

Is there anything in between that can strip the cookie?

Thank you,
Albert



-- 
Web: http://www.tollkuci.com
Follow me on: LinkedIn <http://www.linkedin.com/in/alberttollkuci> Google+
<https://plus.google.com/+AlbertTollku%C3%A7i/posts> Facebook
<https://www.facebook.com/albert.tollkuci> Twitter
<https://twitter.com/AlbertTollkuci> Career 2.0
<http://careers.stackoverflow.com/atollkuci>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160901/9c0c4661/attachment-0001.html>


More information about the varnish-misc mailing list