Has anyone succeeded in getting Varnish 3.x and Drupal 7.x up & running?

Since Varnish 3 the info at https://www.varnish-cache.org/trac/wiki/VarnishAndDrupal
is outdated.

Below is the content of my default.vcl:

I can start Varnish (3.0) but it seems that Varnish isn't caching.

1) In Firebug: I only see one Varnish timestamp instead of two (so varnish isn't serving from cache)
(f.e. X-Varnish    453348501)

2) When I check with 'varnishlog -b' and refresh my Drupal pages, I see that Varnish still makes requests to the web backend instead of serving from cache.

Any ideas what's missing in my default.vcl to get Varnish 3.0 up & running with Drupal 7?

--------------------------

backend default {
 .host = "127.0.0.1";
 .port = "8080";
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

sub vcl_recv {
    if (req.request != "GET" &&
      req.request != "HEAD" &&
      req.request != "PUT" &&
      req.request != "POST" &&
      req.request != "TRACE" &&
      req.request != "OPTIONS" &&
      req.request != "DELETE") {
        /* Non-RFC2616 or CONNECT which is weird. */
        return (pipe);
    }

    if (req.request != "GET" && req.request != "HEAD") {
        /* We only deal with GET and HEAD by default */
        return (pass);
    }

    // Remove has_js and Google Analytics cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");

    if (req.http.Authorization || req.http.Cookie) {
        /* Not cacheable by default */
        return (pass);
    }

   // Remove a ";" prefix, if present.
   set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
   // Remove empty cookies.
   if (req.http.Cookie ~ "^\s*$") {
   unset req.http.Cookie;
   }

  // Skip the Varnish cache for install, update, and cron
  if (req.url ~ "install\.php|update\.php|cron\.php") {
   return (pass);
  }

  // Normalize the Accept-Encoding header
  // as per: http://varnish-cache.org/wiki/FAQ/Compression
  if (req.http.Accept-Encoding) {
   if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
     # No point in compressing these
     remove req.http.Accept-Encoding;
   }
   elsif (req.http.Accept-Encoding ~ "gzip") {
     set req.http.Accept-Encoding = "gzip";
   }
   else {
     # Unknown or deflate algorithm
     remove req.http.Accept-Encoding;
   }
 }

 // Let's have a little grace
 set req.grace = 30s;


    return (lookup);
}

// Strip any cookies before an image/js/css is inserted into cache.
sub vcl_fetch {
  if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
    unset beresp.http.set-cookie;
  }
}

 sub vcl_error {
    set obj.http.Content-Type = "text/html; charset=utf-8";
    set obj.http.Retry-After = "5";
    synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
  <head>
    <title>"} + obj.status + " " + obj.response + {"</title>
  </head>
  <body>
    <h1>Error "} + obj.status + " " + obj.response + {"</h1>
    <p>"} + obj.response + {"</p>
    <h3>Guru Meditation:</h3>
    <p>XID: "} + req.xid + {"</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>
"};
    return (deliver);
}

--------------------------

Regards.

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to