On Tue, Aug 27, 2013 at 04:50:15PM +1000, Paul McInerney wrote:
> I have another problem I am trying to solve.
> One of the sites that sits behind a varnish service, uses an on_page_load 
> module that sends a pop-up asking for an email address (for mail list 
> subscription). It needs to then set a cookie that expires in 30 days (so 
> visitors aren't constantly hit with this pop-up)

I suggest that you rething the problem and use javascript to set the cookie.
Solves everything, except that you need to filter the incoming cookie which is 
pretty simple.


> So, in vcl_fetch, I have this:
>         if (!beresp.http.set-cookie ~ "modaldone"){
>                 unset beresp.http.set-Cookie;
>         }
> Where 'modaldone' is the name of the cookie being set by the backend - yet 
> this still doesn't get set.

Varnishlog will tell you.

You might want to add some printf-style debugging to understand the flow:

    import std;
    sub vcl_fetch {
        if (beresp.http.set-cookie !~ "modaldone") {
            std.log("removing set-cookie: " + beresp.http.set-cookie);
            unset beresp.http.set-cookie;
        }
        [..]
    }

The std.log lines will show up in varnishlog.


> Here's the complete dump of default.vcl   http://pastebin.com/jzNJbs49
> Have I missed something obvious?

I'd recommend rewriting the VCL to not use return() statements. Returning
hit_for_pass without setting the TTL can lead to request serialisation
if the object is uncacheable.

Setting req.backend in vcl_fetch is really a bit to late. We already have the
response from the backend at that point. (unless you plan to restart, with you
don't seem to do)



-- 
With regards,
Lasse Karstensen
Varnish Software AS

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to