r5505 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at varnish-cache.org phk at varnish-cache.org
Thu Nov 4 11:41:13 CET 2010


Author: phk
Date: 2010-11-04 11:41:13 +0100 (Thu, 04 Nov 2010)
New Revision: 5505

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00795.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
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



Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2010-11-04 10:28:58 UTC (rev 5504)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2010-11-04 10:41:13 UTC (rev 5505)
@@ -603,6 +603,8 @@
 
 	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);

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2010-11-04 10:28:58 UTC (rev 5504)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2010-11-04 10:41:13 UTC (rev 5505)
@@ -103,9 +103,8 @@
 		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;
 	}
 

Added: trunk/varnish-cache/bin/varnishtest/tests/r00795.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00795.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00795.vtc	2010-11-04 10:41:13 UTC (rev 5505)
@@ -0,0 +1,42 @@
+# $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




More information about the varnish-commit mailing list