[master] 1f37998 Hit-for-pass objects are not IMS candidates

Martin Blix Grydeland martin at varnish-software.com
Wed Feb 24 13:34:13 CET 2016


commit 1f37998adbc5e68d0b20006436d9bef226ca9bdc
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Feb 24 13:26:05 2016 +0100

    Hit-for-pass objects are not IMS candidates
    
    Original test case by fgsch
    
    Fixes: #1858

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0a4471e..aa3676b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -652,9 +652,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->do_gzip || bo->do_gunzip)
 		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_CHGGZIP, 1);
 
-	if (http_IsStatus(bo->beresp, 200) && (
-	    http_GetHdr(bo->beresp, H_Last_Modified, &p) ||
-	    http_GetHdr(bo->beresp, H_ETag, &p)))
+	if (!(bo->fetch_objcore->flags & OC_F_PASS) &&
+	    http_IsStatus(bo->beresp, 200) && (
+	      http_GetHdr(bo->beresp, H_Last_Modified, &p) ||
+	      http_GetHdr(bo->beresp, H_ETag, &p)))
 		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1);
 
 	if (bo->htc->body_status != BS_NONE &&
diff --git a/bin/varnishtest/tests/r01858.vtc b/bin/varnishtest/tests/r01858.vtc
new file mode 100644
index 0000000..7335b6d
--- /dev/null
+++ b/bin/varnishtest/tests/r01858.vtc
@@ -0,0 +1,38 @@
+varnishtest "Test a hit-for-pass does not issue an IMS request"
+
+server s1 {
+	rxreq
+	txresp \
+	    -hdr {Etag: "foo"} \
+	    -body "foo"
+	rxreq
+	expect req.http.if-none-match == <undef>
+	txresp \
+	    -hdr {Etag: "bar"} \
+	    -body "bar"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		if (beresp.status == 200) {
+			set beresp.ttl = 1s;
+			set beresp.uncacheable = true;
+			return (deliver);
+		}
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.body == "foo"
+
+	delay 1.5
+
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.body == "bar"
+} -run
+



More information about the varnish-commit mailing list