Archives du mot-clef varnish

memo varnish *.vcl

     vcl_recv     Called at the beginning of a request, after the complete
                  request has been received and parsed.  Its purpose is to
                  decide whether or not to serve the request, how to do it,
                  and, if applicanle, which backend to use.
 
     vcl_hit      Called after a cache lookup if the requested document was
                  found in the cache.
 
     vcl_miss     Called after a cache lookup if the requested document was
                  not found in the cache.  Its purpose is to decide whether or
                  not to attempt to retrieve the document from the backend,
                  and which backend to use.
 
     vcl_fetch    Called after a document has been retrieved from the backend,
                  before it is inserted into the cache.
 
     vcl_timeout  Called by the reaper thread when a cached document has
                  reached its expiry time.

vcl_recv

sub vcl_recv {
  if (req.http.host == "be-geek.com" && req.url ~ "\.(gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|ico)$") {
    set req.url = regsub(req.url, "\?.*", "");
    set req.http.user-agent = "mozilla";
    unset req.http.Cookie;
    unset req.http.Authorization;
    set req.backend = nginx;
    return(lookup);
  }
 
  if (req.http.host ~ "^static.bgkcdn.com$" || req.http.host ~ "^static(1|2|3|4).bgkcdn.com$") {
    set req.url = regsub(req.url, "\?.*", "");
    set req.http.user-agent = "mozilla";
    unset req.http.Cookie;
    unset req.http.Authorization;
    set req.backend = nginx;
    return(lookup);
  }
 
  if (req.http.host ~ "^download.hio.fr$") {
    set req.backend = nginx;
    return(pipe);
  }
 
  # Properly handle different encoding types
  // Remove has_js and Google Analytics __* cookies.
  set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
  // Remove a ";" prefix, if present.
  set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
  #return(lookup);
}

memo varnish purge

varnishadm -S /etc/varnish/secret -T :6082 "url.purge .*"
varnishadm -S /etc/varnish/secret -T :6082 'purge req.http.host == "blog.hio.fr"'
varnishadm -S /etc/varnish/secret -T :6082 'purge req.url ~ .(xml|txt)'