Help with caching and failover

nicola sabbi nsabbi at
Wed Aug 1 18:25:34 CEST 2012

I'm trying to configure varnish 3.0.1 as a failover cache in front of a web
server running EZ publish.
What I'd like to do is to let varnish cache pages for up to 4 hours. If the
backend server is seen sick it should serve the last cached page for the
current request (if available), otherwise serve an error page.

The backend polling code is working fine, but every time I tamper with the
test page returning a 404 error code (in order to force the sick mode)
varnish returns a 503 error to the client instead of the cached content,
even though the cache is populated (or so I assume).

The configuration code I'm using is the following:

backend default {
        .host = "";
        .port = "80";
        .probe = {
                .url = "http://backend/test.php";
                .timeout = 10s;
                .interval = 5s;
                .window = 3;
                .threshold = 3;

sub vcl_recv {
  if (req.backend.healthy) {
    set req.grace = 30m;
  } else {
    set req.grace = 4h;

sub vcl_fetch {
   set beresp.grace = 8h;
  #  return(restart);

sub vcl_error {
    set obj.http.Content-Type = "text/html; charset=utf-8";
    set obj.http.Retry-After = "5";
    synthetic {"
Unavailable page!
    return (deliver);

Please, can you explain me what's missing or wrong  with this configuration?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list