302 redirect and hitpass objects

Chris Hecker checker at d6.com
Wed Aug 4 06:59:06 CEST 2010


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
>




More information about the varnish-misc mailing list