cache/503

Laurence Rowe l at lrowe.co.uk
Wed Jun 2 21:31:14 CEST 2010


Different browsers have different Accept-Encoding headers (sometimes
just the difference between a comma followed by a space as the
separator rather than just a comma), so it's best to normalise this
header in ``vcl_recv``. I use something similar to the example at
http://varnish-cache.org/wiki/FAQ/Compression to normalise the header
to either ``gzip`` or remove it completely.

Laurence

On 2 June 2010 19:32, vitaly burshteyn <vburshteyn at gmail.com> wrote:
> Hi folks,
> Just curious if you can point me in the right direction.
> I have 2.0.6 varnish running.  So it seems as if the cache is working and i
> am getting cache hits.
> When i shut down the back end i can still get to the cached pages.
> On the other hand when i try a new browser i keep getting 503 pages.
> Any ideas?
>
>
> backend default {
>   .host = "10.249.129.171";
>         .port = "80"; }
>  sub vcl_recv {
> unset req.http.cookie;
>     if (req.url ~ "^/admin/"){
>     set req.url = regsub(req.url, "^/admin/", "/oops/");   }
>   if (req.url ~ "/affiliates/visa-signature/") {
>         return(pass);    }
> if (req.http.cookie) {
>     set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?",
> "");
>     if (req.http.cookie ~ "^ *$") {
>         remove req.http.cookie;  }  }
>     if (req.url ~ "^/r/\d+/") {
>         return(pass);    }
>     # Don't cache if specific HTTP headers exist
>     if (req.http.Expect) {
>         return(pass);    }
>     if (req.http.Authorization) {
>         return(pass);   }
> return(lookup);}
> sub vcl_deliver {
>     return (deliver);}
> sub vcl_fetch {
>     set obj.ttl = 120m;
> unset obj.http.set-cookie;
>  if (req.url ~  "^/$") {
>  set obj.ttl = 1800s;}
>     # Don't cache error pages
>     if (obj.status == 503) {
>         return(pass);    }
>     if (obj.http.Vary == "Cookie") {
>         remove obj.http.Vary;
>     }
>  if (obj.http.Vary == "Cookie,Accept-Encoding") {
>         set obj.http.Vary = "Accept-Encoding";    }
>     # Anti-dogpiling feature - serve a stale request until a new one
>     # can be fetched, for up to 30s
>     if (!obj.cacheable) {
>        return(pass);       }
>     return(deliver);}
> sub vcl_hit {
>   remove obj.http.Set-Cookie;}
>
> _______________________________________________
> 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