March 10, 2010
Manual:Varnish caching - MediaWiki

Any requests other than a simple ‘get’ will be passed directly through to the web server, along with all requests from logged-in users.

Most common browsers do support compression (gzip or zip) of returned pages. While Varnish itself performs no compression, it is configured here to store separate copies of a page depending on whether the user’s browser supports compression.[4] If a browser accepts both gzip and zip (deflate), the gzip version of the page is served as it is smaller and therefore slightly quicker to display. The browser’s reported capabilities are checked here and the gzip’ped version of pages is served wherever possible.

# vcl_recv is called whenever a request is received   sub vcl_recv {  # Serve objects up to 2 minutes past their expiry if the backend  # is slow to respond.  set req.grace = 120s;    # Use our round-robin "apaches" cluster for the backend.  if (req.http.host ~ "^images.example.org$")   {set req.backend = default;}  else  {set req.backend = apaches;}    # This uses the ACL action called "purge". Basically if a request to  # PURGE the cache comes from anywhere other than localhost, ignore it.  if (req.request == "PURGE")   {if (!client.ip ~ purge)  {error 405 "Not allowed.";}  lookup;}    # Pass any requests that Varnish does not understand straight to the backend.  if (req.request != "GET" && req.request != "HEAD" &&  req.request != "PUT" && req.request != "POST" &&  req.request != "TRACE" && req.request != "OPTIONS" &&  req.request != "DELETE")   {pipe;}     /* Non-RFC2616 or CONNECT which is weird. */    # Pass anything other than GET and HEAD directly.  if (req.request != "GET" && req.request != "HEAD")  {pass;}      /* We only deal with GET and HEAD by default */    # Pass requests from logged-in users directly.  if (req.http.Authorization || req.http.Cookie)  {pass;}      /* Not cacheable by default */    # Pass any requests with the "If-None-Match" header directly.  if (req.http.If-None-Match)  {pass;}    # Force lookup if the request is a no-cache request from the client.  if (req.http.Cache-Control ~ "no-cache")  {purge_url(req.url);}    # normalize Accept-Encoding to reduce vary  if (req.http.Accept-Encoding) {  if (req.http.User-Agent ~ "MSIE 6") {  unset req.http.Accept-Encoding;  } elsif (req.http.Accept-Encoding ~ "gzip") {  set req.http.Accept-Encoding = "gzip";  } elsif (req.http.Accept-Encoding ~ "deflate") {  set req.http.Accept-Encoding = "deflate";  } else {  unset req.http.Accept-Encoding;  }  }    lookup;  }

Posted via web from 原宿工業大学 | Comment »