better hash debug
better hash debug

--- a/varnish-conf/v3/default.vcl
+++ b/varnish-conf/v3/default.vcl
@@ -35,14 +35,14 @@
     }
 
     # redirect yourdomain.com to www.yourdomain.com
-    if (req.http.host ~ "^yourdomain\.com$") {
-        error 750 "http://www.yourdomain.com" + req.url;
-    }
+    #if (req.http.host ~ "^yourdomain\.com$") {
+    #    error 750 "http://www.yourdomain.com" + req.url;
+    #}
 
     # if you use a subdomain for wp-admin, do not cache it
-    if (req.http.host ~ "admin.yourdomain.com") {
-        return(pass);
-    }
+    #if (req.http.host ~ "admin.yourdomain.com") {
+    #    return(pass);
+    #}
 
     ### Check for reasons to bypass the cache!
     # never cache anything except GET/HEAD
@@ -89,10 +89,17 @@
 }
 
 sub vcl_hash {
-    # Add the browser cookie only if a WordPress cookie found.
-    if (req.http.Cookie ~ "wp-postpass_|wordpress_logged_in_|comment_author|PHPSESSID") {
-        hash_data(req.http.Cookie);
+    set req.http.hash = req.url;
+    if (req.http.host) {
+        set req.http.hash = req.http.hash + "#" + req.http.host;
+    } else {
+        set req.http.hash = req.http.hash + "#" + server.ip;
     }
+    # Add the browser cookie only if a WordPress cookie found. Not needed anymore, left here as example
+    #if (req.http.Cookie ~ "wp-postpass_|wordpress_logged_in_|comment_author|PHPSESSID") {
+    #    hash_data(req.http.Cookie);
+    #    set req.http.hash = req.http.hash + "#" + req.http.Cookie;
+    #}
 }
 
 sub vcl_fetch {

--- a/varnish-conf/v3/lib/purge.vcl
+++ b/varnish-conf/v3/lib/purge.vcl
@@ -84,7 +84,7 @@
     }
 
     if (resp.http.X-VC-Debug ~ "true") {
-        set resp.http.X-VC-Hash = req.url+"#"+req.http.host;
+        set resp.http.X-VC-Hash = req.http.hash;
     } else {
         unset resp.http.X-VC-Enabled;
         unset resp.http.X-VC-Cache;

--- a/varnish-conf/v4/default.vcl
+++ b/varnish-conf/v4/default.vcl
@@ -37,15 +37,15 @@
     }
 
     # redirect yourdomain.com to www.yourdomain.com
-    if (req.http.host ~ "^yourdomain\.com$") {
-        set req.http.X-VC-Redirect = "http://www.yourdomain.com" + req.url;
-        return (synth(750, "Moved permanently"));
-    }
+    #if (req.http.host ~ "^yourdomain\.com$") {
+    #    set req.http.X-VC-Redirect = "http://www.yourdomain.com" + req.url;
+    #    return (synth(750, "Moved permanently"));
+    #}
 
     # if you use a subdomain for wp-admin, do not cache it
-    if (req.http.host ~ "admin.yourdomain.com") {
-        return(pass);
-    }
+    #if (req.http.host ~ "admin.yourdomain.com") {
+    #    return(pass);
+    #}
 
     ### Check for reasons to bypass the cache!
     # never cache anything except GET/HEAD
@@ -91,10 +91,17 @@
 }
 
 sub vcl_hash {
-    # Add the browser cookie only if a WordPress cookie found.
-    if (req.http.Cookie ~ "wp-postpass_|wordpress_logged_in_|comment_author|PHPSESSID") {
-        hash_data(req.http.Cookie);
+    set req.http.hash = req.url;
+    if (req.http.host) {
+        set req.http.hash = req.http.hash + "#" + req.http.host;
+    } else {
+        set req.http.hash = req.http.hash + "#" + server.ip;
     }
+    # Add the browser cookie only if a WordPress cookie found. Not needed anymore, left here as example
+    #if (req.http.Cookie ~ "wp-postpass_|wordpress_logged_in_|comment_author|PHPSESSID") {
+    #    hash_data(req.http.Cookie);
+    #    set req.http.hash = req.http.hash + "#" + req.http.Cookie;
+    #}
 }
 
 sub vcl_backend_response {

--- a/varnish-conf/v4/lib/purge.vcl
+++ b/varnish-conf/v4/lib/purge.vcl
@@ -85,7 +85,7 @@
     }
 
     if (resp.http.X-VC-Debug ~ "true") {
-        set resp.http.X-VC-Hash = req.url+"#"+req.http.host;
+        set resp.http.X-VC-Hash = req.http.hash;
     } else {
         unset resp.http.X-VC-Enabled;
         unset resp.http.X-VC-Cache;

comments