Commit 67dd44a2 authored by AlveElde's avatar AlveElde Committed by Poul-Henning Kamp

fetch: A weak LM header does not make an IMS candidate

Avoid marking an object as an IMS candidate when a weak Last-Modified
header is the only validator. In the case where there is an ETag AND a
weak Last-Modified header, add a If-None-Match header, but do not add
an If-Modified-Since header.
parent 63406067
......@@ -274,7 +274,7 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND) &&
(bo->stale_oc->boc != NULL || ObjGetLen(wrk, bo->stale_oc) != 0)) {
AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE));
q = HTTP_GetHdrPack(bo->wrk, bo->stale_oc, H_Last_Modified);
q = RFC2616_Strong_LM(NULL, wrk, bo->stale_oc);
if (q != NULL)
http_PrintfHeader(bo->bereq0,
"If-Modified-Since: %s", q);
......@@ -700,7 +700,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (!(oc->flags & OC_F_HFM) &&
http_IsStatus(bo->beresp, 200) && (
http_GetHdr(bo->beresp, H_Last_Modified, NULL) ||
RFC2616_Strong_LM(bo->beresp, NULL, NULL) != NULL ||
http_GetHdr(bo->beresp, H_ETag, NULL)))
ObjSetFlag(bo->wrk, oc, OF_IMSCAND, 1);
......
varnishtest "Test backend IMS with weak and strong LM"
server s1 {
rxreq
txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" -nodate -body "1"
# When origin does not send a Date, varnish inserts one, prompting IMS
rxreq
expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT"
txresp -status 304 -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr "Date: Wed, 11 Sep 2013 13:36:55 GMT" \
# LM was the same as Date
rxreq
expect req.http.if-modified-since == <undef>
txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr "Date: Wed, 11 Sep 2013 13:36:56 GMT" \
-body "2"
# LM was one second older than Date
rxreq
expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT"
txresp -status 304 -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr "Date: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr {ETag: "foo"}
# LM was the same as Date, but we had an ETag, prompting INM
rxreq
expect req.http.if-modified-since == <undef>
expect req.http.if-none-match == {"foo"}
txresp -status 304 -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr "Date: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr {ETag: "foo"}
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.ttl = 1ms;
set beresp.grace = 0s;
set beresp.keep = 1m;
set beresp.http.was-304 = beresp.was_304;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.body == "1"
expect resp.http.was-304 == "false"
delay 0.1
txreq
rxresp
expect resp.status == 200
expect resp.body == "1"
expect resp.http.was-304 == "true"
delay 0.1
txreq
rxresp
expect resp.status == 200
expect resp.body == "2"
expect resp.http.was-304 == "false"
delay 0.1
txreq
rxresp
expect resp.status == 200
expect resp.body == "2"
expect resp.http.was-304 == "true"
delay 0.1
txreq
rxresp
expect resp.status == 200
expect resp.body == "2"
expect resp.http.was-304 == "true"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment