From 07cc5d7aec2bd02e464f34c42c8d70ffe2d27954 Mon Sep 17 00:00:00 2001 From: David de Boer Date: Tue, 1 Nov 2016 20:32:49 +0100 Subject: [PATCH] Simplify hits counting With Varnish 4.0, the simple obj.hits stopped working and we had to resort to counting the number of spaces in X-Varnish. At least from Varnish 4.0.3 onwards, obj.hits works as it did in Varnish 3. --- resources/config/varnish-3/fos_debug.vcl | 2 +- resources/config/varnish/fos_debug.vcl | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/resources/config/varnish-3/fos_debug.vcl b/resources/config/varnish-3/fos_debug.vcl index 542ec7bf..7aa9474b 100644 --- a/resources/config/varnish-3/fos_debug.vcl +++ b/resources/config/varnish-3/fos_debug.vcl @@ -8,7 +8,7 @@ */ sub fos_debug_deliver { - # Add extra headers if debugging is enabled + # Add X-Cache header if debugging is enabled if (resp.http.X-Cache-Debug) { if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; diff --git a/resources/config/varnish/fos_debug.vcl b/resources/config/varnish/fos_debug.vcl index 0004760d..7aa9474b 100644 --- a/resources/config/varnish/fos_debug.vcl +++ b/resources/config/varnish/fos_debug.vcl @@ -8,12 +8,9 @@ */ sub fos_debug_deliver { - # Add extra headers if debugging is enabled - # In Varnish 4 the obj.hits counter behaviour has changed, so we use a - # different method: if X-Varnish contains only 1 id, we have a miss, if it - # contains more (and therefore a space), we have a hit. + # Add X-Cache header if debugging is enabled if (resp.http.X-Cache-Debug) { - if (resp.http.X-Varnish ~ " ") { + if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; } else { set resp.http.X-Cache = "MISS";