302 redirect and hitpass objects
Caunter, Stefan
scaunter at topscms.com
Wed Aug 4 22:41:52 CEST 2010
Hi Chris,
302 is cacheable. Your vcl logic needs to reverse engineer the site
behaviour you want.
You may find that using && compound conditions gets you the 302 cached
properly
if (obj.http.Cache-Control ~ "private" && obj.status == 302) {
set obj.ttl = 600s;
return(deliver);
}
Watch for a less specific condition grabbing the request and not leaving
it for the more specific condition.
The reload script is essential for an admin. It allows you to extract a
good version if you don't have svn set up. Note the limitations on
reload though. You cannot redefine directors on a reload, it requires a
restart.
Stefan Caunter :: Senior Systems Administrator :: TOPS
e: scaunter at topscms.com :: m: (416) 561-4871
www.thestar.com www.topscms.com
-----Original Message-----
From: varnish-misc-bounces at varnish-cache.org
[mailto:varnish-misc-bounces at varnish-cache.org] On Behalf Of Chris
Hecker
Sent: August-04-10 12:59 AM
To: varnish-misc at varnish-cache.org
Subject: Re: 302 redirect and hitpass objects
Okay, I figured this out in my vcl, it looks like.
Mediawiki is setting Cache-Control: private on 302's it sends back, and
my vcl (part of which was ripped from wikia's) was passing all private
pages. For now, I just check obj.status == 302 and force deliver. Is
this a bad thing for any reason?
if (obj.http.Cache-Control ~ "private") {
if(req.http.Cookie ~"(UserID|_session)") {
set obj.http.X-Cacheable = "NO:Got Session";
} else if(obj.status == 302) {
#force cache this
set obj.ttl = 600s;
set obj.grace = 600s;
set obj.http.X-Cacheable = "YES - FORCED";
deliver;
} else {
set obj.http.X-Cacheable = "NO:Cache-Control=private";
}
pass;
}
It seems to be working, although I'm still digging in my logs.
Also, is there any problem running this script:
http://kristian.blog.linpro.no/2009/02/18/easy-reloading-of-varnish-vcl/
instead of restarting varnish when I change the vcl while the site is
live?
Thanks,
Chris
On 2010/08/03 21:30, Chris Hecker wrote:
>
> I'd like to directly cache 302 redirects. Right now, they're
generating
> HitPass objects, and still hitting the backend. Can I do this?
>
> Chris
>
_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
More information about the varnish-misc
mailing list