[6.0] 1bb0f189f Clear the IMS object attribute when copying from a stale object
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:16 UTC 2018
commit 1bb0f189f0b85bfc506a8bce0adaa9b1cc8c69ec
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Sep 6 23:10:17 2018 +0200
Clear the IMS object attribute when copying from a stale object
The fact that the previous object was IMS/INM eligable does not make
one created from it eligable as well.
Also test for the miss + hfm case with IMS/INM
Fixes #2763
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 6e8097c6a..be6dc162c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -716,6 +716,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
OA_ESIDATA));
AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_FLAGS));
+ ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 0);
AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_GZIPBITS));
if (bo->do_stream) {
diff --git a/bin/varnishtest/tests/r02763.vtc b/bin/varnishtest/tests/r02763.vtc
new file mode 100644
index 000000000..3488d7c95
--- /dev/null
+++ b/bin/varnishtest/tests/r02763.vtc
@@ -0,0 +1,68 @@
+varnishtest "Cacheable IMS replaced by HFM object"
+
+server s1 {
+ rxreq
+ expect req.url == "/etag"
+ txresp -hdr "ETag: foo" -bodylen 7
+
+ rxreq
+ expect req.url == "/etag"
+ expect req.http.If-None-Match == "foo"
+ txresp -status 304 -hdr "ETag: foo"
+
+ rxreq
+ expect req.url == "/etag"
+ txresp -hdr "ETag: foo" -bodylen 7
+} -start
+
+varnish v1 -vcl+backend {
+
+ sub vcl_miss {
+ set req.http.X-Cache = "MISS";
+ }
+
+ sub vcl_pass {
+ set req.http.X-Cache = "PASS";
+ }
+
+ sub vcl_backend_response {
+ if (bereq.http.HFM) {
+ set beresp.uncacheable = true;
+ } else {
+ set beresp.ttl = 0.0001s;
+ set beresp.grace = 0s;
+ set beresp.keep = 1m;
+ }
+ return (deliver);
+ }
+
+ sub vcl_deliver {
+ set resp.http.X-Cache = req.http.X-Cache;
+ }
+
+} -start
+
+client c1 {
+ txreq -url "/etag"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 7
+ expect resp.http.ETag == "foo"
+ expect resp.http.X-Cache == "MISS"
+
+ delay 0.1
+
+ txreq -url "/etag" -hdr "HFM: true"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 7
+ expect resp.http.ETag == "foo"
+ expect resp.http.X-Cache == "MISS"
+
+ txreq -url "/etag"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 7
+ expect resp.http.ETag == "foo"
+ expect resp.http.X-Cache == "MISS"
+} -run
More information about the varnish-commit
mailing list