r3719 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests

tfheen at projects.linpro.no tfheen at projects.linpro.no
Tue Feb 10 15:32:11 CET 2009


Author: tfheen
Date: 2009-02-10 15:32:10 +0100 (Tue, 10 Feb 2009)
New Revision: 3719

Added:
   branches/2.0/varnish-cache/bin/varnishtest/tests/r00425.vtc
Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_center.c
Log:
Merge r3537: 

Enforce a minimum ttl for "hit for pass" objects to prevent a value
of zero from serializing access to an object with very draconian
backend cache-control headers.

We could get far even with a one second TTL, but following our general
"there is a reason people put Varnish there in the first place" logic
we use the default_ttl parameter (default: 120 s) for this value.

If another value is desired, this can be set in vcl_fetch, even if it
looks somewhat counter-intuitive:

        sub vcl_fetch {
                if (obj.http.set-cookie) {
                        set obj.ttl = 10s;
                        pass;
                }
        }

Fixes #425



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-02-10 14:25:49 UTC (rev 3718)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-02-10 14:32:10 UTC (rev 3719)
@@ -413,6 +413,8 @@
 		return (0);
 	case VCL_RET_PASS:
 		sp->obj->pass = 1;
+		if (sp->obj->ttl - sp->t_req < params->default_ttl)
+			sp->obj->ttl = sp->t_req + params->default_ttl;
 		break;
 	case VCL_RET_DELIVER:
 		break;

Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/r00425.vtc (from rev 3537, trunk/varnish-cache/bin/varnishtest/tests/r00425.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/r00425.vtc	                        (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/r00425.vtc	2009-02-10 14:32:10 UTC (rev 3719)
@@ -0,0 +1,34 @@
+# $Id$
+
+test "check late pass stalling"
+
+server s1 {
+	rxreq
+	txresp \
+	    -hdr "Set-Cookie: foo=bar" \
+	    -hdr "Expires: Thu, 19 Nov 1981 08:52:00 GMT" \
+	    -body "1111\n"
+	rxreq
+	txresp \
+	    -hdr "Set-Cookie: foo=bar" \
+	    -hdr "Expires: Thu, 19 Nov 1981 08:52:00 GMT" \
+	    -body "22222n"
+	rxreq
+	txresp \
+	    -hdr "Set-Cookie: foo=bar" \
+	    -hdr "Expires: Thu, 19 Nov 1981 08:52:00 GMT" \
+	    -body "33333n"
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+	txreq
+	rxresp
+	txreq
+	rxresp
+	txreq
+	rxresp
+} -run
+
+varnish v1 -expect cache_hitpass == 2



More information about the varnish-commit mailing list