Skip to content

Commit 07cc5d7

Browse files
committed
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.
1 parent 2c6f31b commit 07cc5d7

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

resources/config/varnish-3/fos_debug.vcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
sub fos_debug_deliver {
11-
# Add extra headers if debugging is enabled
11+
# Add X-Cache header if debugging is enabled
1212
if (resp.http.X-Cache-Debug) {
1313
if (obj.hits > 0) {
1414
set resp.http.X-Cache = "HIT";

resources/config/varnish/fos_debug.vcl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
*/
99

1010
sub fos_debug_deliver {
11-
# Add extra headers if debugging is enabled
12-
# In Varnish 4 the obj.hits counter behaviour has changed, so we use a
13-
# different method: if X-Varnish contains only 1 id, we have a miss, if it
14-
# contains more (and therefore a space), we have a hit.
11+
# Add X-Cache header if debugging is enabled
1512
if (resp.http.X-Cache-Debug) {
16-
if (resp.http.X-Varnish ~ " ") {
13+
if (obj.hits > 0) {
1714
set resp.http.X-Cache = "HIT";
1815
} else {
1916
set resp.http.X-Cache = "MISS";

0 commit comments

Comments
 (0)