Commit 3bd239e9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change how we do If-Modified-Since on objects without a Last-Modified

header.

Until now, we have not allowed IMS on objects without LM header but
after due consideration of our role as web-server, that restriction is
found too hard:  Varnish will, by definition, not find and object which
is not valid, so we can trust the time we put it into the cache to
be the LM date.

But we can not synthesize a LM header based on this, as this would allow
down-stream client-side caches to make unwarranted decisions (see RFC2616
13.3.4 p88)

Fixes: #795



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5505 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 955519b7
......@@ -603,6 +603,8 @@ cnt_fetch(struct sess *sp)
if (http_GetHdr(hp, H_Last_Modified, &b))
sp->obj->last_modified = TIM_parse(b);
else
sp->obj->last_modified = sp->wrk->entered;
i = FetchBody(sp);
AZ(sp->wrk->wfd);
......
......@@ -103,9 +103,8 @@ res_do_conds(struct sess *sp)
ims = TIM_parse(p);
if (ims > sp->t_req) /* [RFC2616 14.25] */
return (0);
if (sp->obj->last_modified > ims) {
if (sp->obj->last_modified > ims)
return (0);
}
do_cond = 1;
}
......
# $Id$
test "Content-Length in pass'ed 304 does not trigger body fetch"
server s1 {
rxreq
txresp -hdr "Last-Modified: ${date}" -body "FOO"
rxreq
txresp -body "FOO"
} -start
varnish v1 -vcl+backend { } -start
# First load the objects into cache
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.bodylen == 3
txreq -url "/bar"
rxresp
expect resp.status == 200
expect resp.bodylen == 3
} -run
# Wait, so we know ${date} to be higher
delay 1
client c1 {
txreq -hdr "If-Modified-Since: ${date}"
rxresp
expect resp.status == 304
expect resp.bodylen == 0
txreq -url "/bar" -hdr "If-Modified-Since: ${date}"
rxresp
expect resp.status == 304
expect resp.bodylen == 0
} -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