[master] 278d90f Update the documentation for obj.hits to reflect code reality.
Poul-Henning Kamp
phk at FreeBSD.org
Mon May 5 09:02:12 CEST 2014
commit 278d90fdc0008a55405550482ccf9bc4d74f18dc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 5 07:00:56 2014 +0000
Update the documentation for obj.hits to reflect code reality.
In 4.x we changed obj.hits to be read-only, and to count all variants
under the same hash-key (= same objhdr).
Since we cannot trivially tell if a ban hits all Vary: values or
just some of them, there is no sane heuristic to fiddle obj.hits
on bans that would Do The Right Thing.
Fixes #1492
diff --git a/bin/varnishtest/tests/v00039.vtc b/bin/varnishtest/tests/v00039.vtc
new file mode 100644
index 0000000..90bc865
--- /dev/null
+++ b/bin/varnishtest/tests/v00039.vtc
@@ -0,0 +1,58 @@
+varnishtest "obj.hits vs Vary"
+
+server s1 {
+ rxreq
+ txresp -hdr "Vary: bar" -body "foobar"
+ rxreq
+ txresp -hdr "Vary: bar" -body "barf"
+} -start
+
+varnish v1 \
+ -arg "-p ban_lurker_sleep=0.01" \
+ -arg "-p ban_lurker_age=0.01" \
+ -vcl+backend {
+ sub vcl_deliver {
+ set resp.http.hits = obj.hits;
+ }
+ } -start
+
+client c1 {
+ # This is a miss -> hits == 0
+ txreq -url "/" -hdr "Bar: 1"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 6
+ expect resp.http.hits == 0
+
+ # This is a hit -> hits == 1
+ txreq -url "/" -hdr "Bar: 1"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 6
+ expect resp.http.hits == 1
+
+ # This is a miss on different vary -> hits still == 1
+ txreq -url "/" -hdr "Bar: 2"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 4
+ expect resp.http.hits == 1
+
+ # This is a hit -> hits == 2
+ txreq -url "/" -hdr "Bar: 2"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 4
+ expect resp.http.hits == 2
+
+} -run
+
+# Ban everything on this hash-key
+varnish v1 -cliok "ban obj.http.vary ~ ."
+delay 1
+
+# And run the entire test again to see that obj.hits got reset.
+
+server s1 -start
+
+client c1 -run
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 57f22ca..1e523f1 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -511,9 +511,12 @@ sp_variables = [
'INT',
( 'hit', 'deliver',),
( ), """
- The approximate number of times the object has been
- delivered. A value of 0 indicates a cache miss.
- This variable is also available in vcl_deliver.
+ The count of cache-hits on this hash-key since it was
+ last instantiated. This counts cache-hits across all
+ Vary:-ants on this hash-key.
+ The counter will only be reset to zero if/when all objects
+ with this hash-key have disappeared from cache.
+ NB: obj.hits == 0 does *not* indicate a cache miss.
"""
),
('obj.http.',
More information about the varnish-commit
mailing list