cleanup, external files for backend/acl
cleanup, external files for backend/acl

--- /dev/null
+++ b/varnish-conf/v3/conf/acl.vcl
@@ -1,1 +1,10 @@
+acl cloudflare {
+    # set this ip to your Railgun IP (if applicable)
+    # "1.2.3.4";
+}
 
+acl purge {
+    "localhost";
+    "127.0.0.1";
+    #"192.168.0.2";
+}

--- /dev/null
+++ b/varnish-conf/v3/conf/backend.vcl
@@ -1,1 +1,4 @@
-
+backend default {
+    .host = "192.168.0.2";
+    .port = "80";
+}

--- a/varnish-conf/v3/default.vcl
+++ b/varnish-conf/v3/default.vcl
@@ -1,7 +1,5 @@
-backend default {
-    .host = "192.168.0.2";
-    .port = "80";
-}
+include "conf/backend.vcl";
+include "conf/acl.vcl";
 
 import std;
 
@@ -11,17 +9,6 @@
 include "lib/bigfiles.vcl";
 include "lib/static.vcl";
 
-acl cloudflare {
-    # set this ip to your Railgun IP (if applicable)
-    # "1.2.3.4";
-}
-
-acl purge {
-    "localhost";
-    "127.0.0.1";
-    #"192.168.0.2";
-}
-
 # Pick just one of the following:
 # (or don't use either of these if your application is "adaptive")
 # include "lib/mobile_cache.vcl";
@@ -29,9 +16,6 @@
 
 ### WordPress-specific config ###
 sub vcl_recv {
-    # unset X-VC-Cacheable header from client
-    unset req.http.X-VC-Cacheable;
-
     # pipe on weird http methods
     if (req.request !~ "^GET|HEAD|PUT|POST|TRACE|OPTIONS|DELETE$") {
         return(pipe);

--- a/varnish-conf/v3/lib/purge.vcl
+++ b/varnish-conf/v3/lib/purge.vcl
@@ -33,8 +33,9 @@
 # always set the X-VC-Purge-Method header.
 
 sub vcl_recv {
+    set req.http.X-VC-My-Purge-Key = "ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4";
     if (req.request == "PURGE") {
-        if (req.http.X-VC-Purge-Key == "ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4") {
+        if (req.http.X-VC-Purge-Key == req.http.X-VC-My-Purge-Key) {
             set req.http.X-VC-Purge-Key-Auth = "true";
         } else {
             set req.http.X-VC-Purge-Key-Auth = "false";
@@ -64,6 +65,10 @@
         }
         error 200 "Purged " + req.url + " " + req.http.host;
     }
+    unset req.http.X-VC-My-Purge-Key;
+    # unset Varnish Caching custom headers from client
+    unset req.http.X-VC-Cacheable;
+    unset req.http.X-VC-Debug;
 }
 
 sub vcl_fetch {
@@ -83,12 +88,16 @@
         set resp.http.X-VC-Cache = "MISS";
     }
 
-    if (resp.http.X-VC-Debug ~ "true") {
+    if (req.http.X-VC-Debug ~ "true" || resp.http.X-VC-Debug ~ "true") {
         set resp.http.X-VC-Hash = req.http.hash;
+        if (req.http.X-VC-DebugMessage) {
+            set resp.http.X-VC-DebugMessage = req.http.X-VC-DebugMessage;
+        }
     } else {
         unset resp.http.X-VC-Enabled;
         unset resp.http.X-VC-Cache;
         unset resp.http.X-VC-Debug;
+        unset resp.http.X-VC-DebugMessage;
         unset resp.http.X-VC-Cacheable;
         unset resp.http.X-VC-Purge-Key-Auth;
         unset resp.http.X-VC-TTL;

--- a/varnish-conf/v3/lib/static.vcl
+++ b/varnish-conf/v3/lib/static.vcl
@@ -2,10 +2,15 @@
 
 sub vcl_recv {
     if (req.request ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)(\?.*)?$") {
-        # disable this if you want
-        if (req.url ~ "nocache") {
-            return(pass);
-        }
+        # enable this if you want
+        #if (req.url ~ "debug") {
+        #    set req.http.X-VC-Debug = "true";
+        #}
+        # enable this if you need it
+        #if (req.url ~ "nocache") {
+        #    set req.http.X-VC-Cacheable = "NO:Not cacheable, nocache in URL";
+        #    return(pass);
+        #}
         set req.url = regsub(req.url, "\?.*$", "");
         # unset cookie only if no http auth
         if (!req.http.Authorization) {
@@ -19,8 +24,9 @@
 sub vcl_fetch {
     if (req.request ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
         # overwrite ttl with X-VC-TTL
-        set beresp.http.X-VC-TTL = "24";
-        set beresp.ttl = std.duration(beresp.http.X-VC-TTL + "h", 0s);
+        set beresp.http.X-VC-TTL = 24*60*60;
+        set beresp.ttl = std.duration(beresp.http.X-VC-TTL + "s", 0s);
+        set beresp.http.X-VC-Cacheable = "YES:Is cacheable, ttl: " + beresp.ttl;
         set beresp.grace = 2m;
     }
 }

--- /dev/null
+++ b/varnish-conf/v4/conf/acl.vcl
@@ -1,1 +1,10 @@
+acl cloudflare {
+    # set this ip to your Railgun IP (if applicable)
+    # "1.2.3.4";
+}
 
+acl purge {
+    "localhost";
+    "127.0.0.1";
+    #"192.168.0.2";
+}

--- /dev/null
+++ b/varnish-conf/v4/conf/backend.vcl
@@ -1,1 +1,4 @@
-
+backend default {
+    .host = "192.168.0.2";
+    .port = "80";
+}

--- a/varnish-conf/v4/default.vcl
+++ b/varnish-conf/v4/default.vcl
@@ -1,9 +1,7 @@
 vcl 4.0;
 
-backend default {
-    .host = "192.168.0.2";
-    .port = "80";
-}
+include "conf/backend.vcl";
+include "conf/acl.vcl";
 
 import std;
 
@@ -13,17 +11,6 @@
 include "lib/bigfiles.vcl";
 include "lib/static.vcl";
 
-acl cloudflare {
-    # set this ip to your Railgun IP (if applicable)
-    # "1.2.3.4";
-}
-
-acl purge {
-    "localhost";
-    "127.0.0.1";
-    #"192.168.0.2";
-}
-
 # Pick just one of the following:
 # (or don't use either of these if your application is "adaptive")
 # include "lib/mobile_cache.vcl";
@@ -31,9 +18,6 @@
 
 ### WordPress-specific config ###
 sub vcl_recv {
-    # unset X-VC-Cacheable header from client
-    unset req.http.X-VC-Cacheable;
-
     # pipe on weird http methods
     if (req.method !~ "^GET|HEAD|PUT|POST|TRACE|OPTIONS|DELETE$") {
         return(pipe);

--- a/varnish-conf/v4/lib/bigfiles.vcl
+++ b/varnish-conf/v4/lib/bigfiles.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # bigfiles.vcl -- Bypass Cache for Large Files
 
 sub vcl_backend_response {

--- a/varnish-conf/v4/lib/bigfiles_pipe.vcl
+++ b/varnish-conf/v4/lib/bigfiles_pipe.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # bigfiles_pipe.vcl -- Pipe for Large Files
 
 # You must have "import std;" in your main vcl:

--- a/varnish-conf/v4/lib/cloudflare.vcl
+++ b/varnish-conf/v4/lib/cloudflare.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # cloudflare.vcl -- CloudFlare HTTP Headers
 
 # This should generally be loaded first to make sure that the headers

--- a/varnish-conf/v4/lib/mobile_cache.vcl
+++ b/varnish-conf/v4/lib/mobile_cache.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # mobile_cache.vcl -- Separate cache for mobile clients
 
 # If the User-Agent looks like a mobile device, then we add the string

--- a/varnish-conf/v4/lib/mobile_pass.vcl
+++ b/varnish-conf/v4/lib/mobile_pass.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # mobile_pass.vcl -- Mobile pass-through support for Varnish
 
 # This simply bypasses the cache for anything that looks like a mobile

--- a/varnish-conf/v4/lib/purge.vcl
+++ b/varnish-conf/v4/lib/purge.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # purge.vcl -- Cache Purge Library for Varnish
 
 # Regex purging
@@ -34,8 +33,9 @@
 # always set the X-VC-Purge-Method header.
 
 sub vcl_recv {
+    set req.http.X-VC-My-Purge-Key = "ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4";
     if (req.method == "PURGE") {
-        if (req.http.X-VC-Purge-Key == "ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4") {
+        if (req.http.X-VC-Purge-Key == req.http.X-VC-My-Purge-Key) {
             set req.http.X-VC-Purge-Key-Auth = "true";
         } else {
             set req.http.X-VC-Purge-Key-Auth = "false";
@@ -65,6 +65,10 @@
         }
         return (synth(200,"Purged " + req.url + " " + req.http.host));
     }
+    unset req.http.X-VC-My-Purge-Key;
+    # unset Varnish Caching custom headers from client
+    unset req.http.X-VC-Cacheable;
+    unset req.http.X-VC-Debug;
 }
 
 sub vcl_backend_response {
@@ -84,12 +88,16 @@
         set resp.http.X-VC-Cache = "MISS";
     }
 
-    if (resp.http.X-VC-Debug ~ "true") {
+    if (req.http.X-VC-Debug ~ "true" || resp.http.X-VC-Debug ~ "true") {
         set resp.http.X-VC-Hash = req.http.hash;
+        if (req.http.X-VC-DebugMessage) {
+            set resp.http.X-VC-DebugMessage = req.http.X-VC-DebugMessage;
+        }
     } else {
         unset resp.http.X-VC-Enabled;
         unset resp.http.X-VC-Cache;
         unset resp.http.X-VC-Debug;
+        unset resp.http.X-VC-DebugMessage;
         unset resp.http.X-VC-Cacheable;
         unset resp.http.X-VC-Purge-Key-Auth;
         unset resp.http.X-VC-TTL;

--- a/varnish-conf/v4/lib/static.vcl
+++ b/varnish-conf/v4/lib/static.vcl
@@ -1,12 +1,16 @@
-vcl 4.0;
 # static.vcl -- Static File Caching for Varnish
 
 sub vcl_recv {
     if (req.method ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)(\?.*)?$") {
-        # disable this if you want
-        if (req.url ~ "nocache") {
-            return(pass);
-        }
+        # enable this if you want
+        #if (req.url ~ "debug") {
+        #    set req.http.X-VC-Debug = "true";
+        #}
+        # enable this if you need it
+        #if (req.url ~ "nocache") {
+        #    set req.http.X-VC-Cacheable = "NO:Not cacheable, nocache in URL";
+        #    return(pass);
+        #}
         set req.url = regsub(req.url, "\?.*$", "");
         # unset cookie only if no http auth
         if (!req.http.Authorization) {
@@ -19,8 +23,9 @@
 sub vcl_backend_response {
     if (bereq.method ~ "^(GET|HEAD)$" && bereq.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
         # overwrite ttl with X-VC-TTL
-        set beresp.http.X-VC-TTL = "24";
-        set beresp.ttl = std.duration(beresp.http.X-VC-TTL + "h", 0s);
+        set beresp.http.X-VC-TTL = 24*60*60;
+        set beresp.ttl = std.duration(beresp.http.X-VC-TTL + "s", 0s);
+        set beresp.http.X-VC-Cacheable = "YES:Is cacheable, ttl: " + beresp.ttl;
     }
 }
 

--- a/varnish-conf/v4/lib/xforward.vcl
+++ b/varnish-conf/v4/lib/xforward.vcl
@@ -1,4 +1,3 @@
-vcl 4.0;
 # xforward.vcl -- X-Forwarded-For HTTP Headers
 
 # This should generally be loaded first to make sure that the headers

comments