varnish won't keep site up

Tim Dunphy bluethundr at gmail.com
Fri Feb 13 07:35:40 CET 2015


Hi all,

 I seem to be getting a pretty good cache / hit ratio on my current VCL
config.

Hitrate avg:     0.9077   0.9242   0.9242

However I notice that if I stop my web server and go to the site I'm
working with, instead of seeing a cached copy of the site, I instead see a
varnish guru meditation error.

I thought that the key to getting the site cached in such a way that you
could completely stop the webserver and still view the site via the cache
had a lot to do with this following line:

 if(req.http.cookie ~ "cc_loggedin" || req.http.cookie ~ "PHPSESSID"){
        return(pass);
     }

I had a look at the cookies for the site and put them in the above line.
However I get no results with that.

Here's the full VCL file:

probe healthcheck {
  .url = "/healthcheck.php";
  .timeout = 5s;
  .interval = 2s;
  .window = 5;
  .threshold = 3;
}

backend web1  {
  .host = "10.10.10.94";
  .port = "80";
  .probe = healthcheck;
  .connect_timeout = 30s;
  .first_byte_timeout = 30s;
  .between_bytes_timeout = 30s;
  .max_connections = 70;
}


director www client {
  { .backend = web1 ; .weight = 2;  }
 }


sub vcl_recv {


    set req.backend = www;

     if(req.http.cookie ~ "cc_loggedin" || req.http.cookie ~ "PHPSESSID"){
        return(pass);
     }


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

    return (lookup);
}

sub vcl_fetch {

   if ( req.http.host == "www.ref.mydomain.com" || req.http.host == "
www.beta.mydomain.com" ) {
   set beresp.ttl = 3600s;
   }

   if ( req.url ~ "^/index.php$" || req.url ~
 "^/cometchat/cometchat_receive.php$") {
      set beresp.ttl = 3600s;
   }

    set beresp.grace = 4h;

    return (deliver);
}

sub vcl_deliver {
     if (obj.hits> 0) {
      set resp.http.X-Cache = "HIT";
     } else {
        set resp.http.X-Cache = "MISS";
     }
 }


Could someone have a look at this VCL and give some opinion as to why this
is happening?

Thanks
Tim
-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150213/4e4f4205/attachment.html>


More information about the varnish-misc mailing list