Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- backend default {
- .host = "127.0.0.1";
- .port = "8888";
- .probe = {
- .request = "HEAD / HTTP/1.1"
- "Host: mylocalsite.co"
- "Connection: close";
- .timeout = 5s;
- .interval = 5s;
- }
- }
- sub vcl_fetch {
- set beresp.ttl = 10m;
- unset beresp.http.Set-Cookie;
- if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
- unset beresp.http.set-cookie;
- set beresp.ttl = 20m;
- } else {
- set beresp.do_esi = true;
- }
- return(deliver);
- }
- sub vcl_recv {
- # Either the admin pages or the login
- if (req.url ~ "/admin/?") {
- # Don't cache, pass to backend
- return (pass);
- }
- # Remove the "has_js" cookie
- set req.http.Cookie = regsuball(req.http.Cookie, "has_js=[^;]+(; )?", "");
- # Remove the "Drupal.toolbar.collapsed" cookie
- set req.http.Cookie = regsuball(req.http.Cookie, "Drupal.toolbar.collapsed=[^;]+(; )?", "");
- # Remove any Google Analytics based cookies
- set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?", "");
- # Remove the Quant Capital cookies (added by some plugin, all __qca)
- set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", "");
- set req.http.Cookie = regsuball(req.http.Cookie, "__qca=[^;]+(; )?", "");
- set req.http.Cookie = regsuball(req.http.Cookie, "_chartbeat2=[^;]+(; )?", "");
- set req.http.Cookie = regsuball(req.http.Cookie, "Drupal.tableDrag.showWeight=[^;]+(; )?", "");
- set req.http.Cookie = regsuball(req.http.Cookie, "undefined=[^;]+(; )?", "");
- set req.http.Cookie = ";" + req.http.Cookie;
- set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
- set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|NO_CACHE)=", "; \1=");
- set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
- set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
- // 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*", "");
- # Are there cookies left with only spaces or that are empty?
- if (req.http.cookie ~ "^ *$") {
- unset req.http.cookie;
- }
- # Anything else left?
- if (!req.http.cookie) {
- unset req.http.cookie;
- }
- unset req.http.cookie;
- }
- sub vcl_deliver {
- if (obj.hits > 0) {
- set resp.http.X-Varnish-Cache = "HIT";
- }
- else {
- set resp.http.X-Varnish-Cache = "MISS";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement