Varnish Configuration

Extra Header Information
Add some extra HTTP header details to tell whether the page you are getting came from the Varnish cache by adding this snippet to /usr/local/etc/varnish/drupal.vcl:

sub vcl_deliver {
  #add cache hit data
  if (obj.hits > 0) {
    #if hit add hit count
    set resp.http.X-Varnish-Cache = "HIT";
    set resp.http.X-Cache-Hits = obj.hits;
  } else {
    set resp.http.X-Varnish-Cache = "MISS";
  }
}

Grace for Misbehaving Backends
http://varnish-cache.org/trac/wiki/VCLExampleGrace

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

sub vcl_fetch {
   set beresp.grace = 1h;
}

You'll also need to enable polling for your backend:
http://varnish-cache.org/trac/wiki/BackendPolling

backend default {
  .host = "127.0.0.1";
  .port = "8080";
  .connect_timeout = 600s;
  .first_byte_timeout = 600s;
  .between_bytes_timeout = 600s;
  .probe = {
    .url = "/sites/default/files/garland_logo.png";
    .timeout = 0.3 s;
    .window = 8;
    .threshold = 3;
  }

<a href="http://www.midwesternmac.com/blogs/jeff-geerling/debugging-varnish-vcl">Debugging Varnish VCL configuration</a>
}

Recent Updates

  • 2 years 2 weeks ago
  • 2 years 2 weeks ago
  • 2 years 2 weeks ago
    php 8.x
  • 2 years 2 weeks ago
    10.6.7
  • 2 years 3 weeks ago
    Drop Centos 5/6 stuff