[experimental-ims] 321be3e Merged conditional backend request feature

Geoff Simmons geoff at varnish-cache.org
Fri Jul 8 11:47:53 CEST 2011


commit 321be3ed610227bcb8dd88a6bb29e2227c1fa6c6
Author: Geoff Simmons <geoff at uplex.de>
Date:   Thu Jun 2 21:42:28 2011 +0200

    Merged conditional backend request feature

diff --git a/bin/varnishtest/tests/i00000.vtc b/bin/varnishtest/tests/i00000.vtc
new file mode 100644
index 0000000..773e1e5
--- /dev/null
+++ b/bin/varnishtest/tests/i00000.vtc
@@ -0,0 +1,498 @@
+# $Id$
+
+test "VCL compiler coverage test: conditional refresh extension"
+
+## stale_obj is r/o in miss, fetch and error, illegal everywhere else
+
+varnish v1 -vcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_miss { if (stale_obj) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_miss { set stale_obj = true; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.proto ~ "foo") { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.proto = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.status == 200) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.status = 200; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.response ~ "foo") { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.response = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.hits > 100) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.hits = 100; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.http.Foo ~ "foo") { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.http.Foo = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.ttl > 1m) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.ttl = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.grace > 1m) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.grace = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.lastuse > 1m) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.lastuse = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (stale_obj.keep > 1m) { return(pass); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set stale_obj.keep = 1m; }
+}
+
+varnish v1 -vcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_fetch { if (stale_obj) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_fetch { set stale_obj = true; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.proto ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.proto = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.status == 200) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.status = 200; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.response ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.response = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.hits > 100) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.hits = 100; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.http.Foo ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.http.Foo = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.ttl > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.ttl = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.grace > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.grace = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.lastuse > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.lastuse = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (stale_obj.keep > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set stale_obj.keep = 1m; }
+}
+
+varnish v1 -vcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_error { if (stale_obj) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+        backend b { .host = "127.0.0.1"; }
+        sub vcl_error { set stale_obj = true; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.proto ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.proto = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.status == 200) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.status = 200; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.response ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.response = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.hits > 100) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.hits = 100; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.http.Foo ~ "foo") { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.http.Foo = "foo"; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.ttl > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.ttl = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.grace > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.grace = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.lastuse > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.lastuse = 1m; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (stale_obj.keep > 1m) { return(deliver); } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set stale_obj.keep = 1m; }
+}
+
+## keep is r/w for req everywhere
+##  r/w for beresp in fetch
+##  r/w for obj in hit and error (like ttl and grace)
+##  r/o for stale_obj in fetch, miss and error (already tested)
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_recv { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_recv { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pipe { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pipe { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pass { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pass { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hash { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hash { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hit { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hit { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_deliver { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_deliver { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { set req.keep = 1s; }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (req.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (beresp.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set beresp.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hit { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -vcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_error { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_miss { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_fetch { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_recv { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_recv { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pipe { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pipe { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pass { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_pass { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hash { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_hash { set obj.keep = 1s; }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_deliver { if (obj.keep > 1s) { set req.keep = 1s; } }
+}
+
+varnish v1 -badvcl {
+	backend b { .host = "127.0.0.1"; }
+	sub vcl_deliver { set obj.keep = 1s; }
+}
+
+varnish v1 -cliok "param.show default_keep"
+
+varnish v1 -cliok "param.set default_keep 30s"
+
+## XXX: This is not caught as an error
+#varnish v1 -clierr 106 "param.set default_keep foo"
+
diff --git a/bin/varnishtest/tests/i00001.vtc b/bin/varnishtest/tests/i00001.vtc
new file mode 100644
index 0000000..488305f
--- /dev/null
+++ b/bin/varnishtest/tests/i00001.vtc
@@ -0,0 +1,271 @@
+# $Id$
+
+test "Test basic conditional requests to backends"
+
+## By default (default_keep = default_grace), cond. requests happen during grace
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -hdr "ETag: foo" \
+            -body "123456"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 304
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.ttl = 0.5s;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-length == 6
+        expect resp.bodylen == 6
+        expect resp.http.Age == 0
+} -run
+
+delay 0.6
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## With keep > 0, using both If-Modified-Since and If-None-Match
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -hdr "ETag: foo" \
+            -body "123456"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 200 \
+            -hdr "Last-Modified: Wed, 27 Jun 2008 12:00:01 GMT" \
+            -hdr "ETag: foo" \
+            -body "ABCDEF"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Wed, 27 Jun 2008 12:00:01 GMT"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 304
+
+} -start
+
+varnish v1 -vcl {
+        backend s1 {
+                .host = "${s1_addr}"; .port = "${s1_port}";
+        }
+
+        sub vcl_fetch {
+            set beresp.http.X-Original-Keep = beresp.keep;
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.ETag == "foo"
+        expect resp.http.content-length == 6
+        expect resp.bodylen == 6
+        expect resp.http.Age == 0
+        expect resp.http.X-Original-Keep == 10.000
+}
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 2
+varnish v1 -expect cond_not_validated == 1
+
+server s1 -wait
+varnish v1 -stop
+
+## Just If-Modified-Since
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "123456"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 \
+            -hdr "Last-Modified: Wed, 27 Jun 2008 12:00:01 GMT" \
+            -body "ABCDEF"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Wed, 27 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+} -start
+
+varnish v1 -vcl {
+        backend s1 {
+                .host = "${s1_addr}"; .port = "${s1_port}";
+        }
+        sub vcl_fetch {
+            set beresp.http.X-Original-Keep = beresp.keep;
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-length == 6
+        expect resp.bodylen == 6
+        expect resp.http.Age == 0
+        expect resp.http.X-Original-Keep == 10.000
+}
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 2
+varnish v1 -expect cond_not_validated == 1
+
+server s1 -wait
+varnish v1 -stop
+
+## Just If-None-Match
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "ETag: foo" \
+            -body "123456"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-None-Match == "foo"
+        txresp -status 200 \
+            -hdr "ETag: bar" \
+            -body "ABCDEF"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-None-Match == "bar"
+        txresp -status 304
+
+} -start
+
+varnish v1 -vcl {
+        backend s1 {
+                .host = "${s1_addr}"; .port = "${s1_port}";
+        }
+        sub vcl_fetch {
+            set beresp.http.X-Original-Keep = beresp.keep;
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.ETag == "foo"
+        expect resp.http.content-length == 6
+        expect resp.bodylen == 6
+        expect resp.http.Age == 0
+        expect resp.http.X-Original-Keep == 10.000
+}
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.ETag == "bar"
+        expect resp.http.content-length == 6
+        expect resp.bodylen == 6
+        expect resp.http.Age == 0
+        expect resp.http.X-Original-Keep == 10.000
+}
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c2 -run
+
+delay 1.1
+
+client c2 -run
+
+varnish v1 -expect fetch_304 == 2
+varnish v1 -expect cond_not_validated == 1
diff --git a/bin/varnishtest/tests/i00002.vtc b/bin/varnishtest/tests/i00002.vtc
new file mode 100644
index 0000000..3725532
--- /dev/null
+++ b/bin/varnishtest/tests/i00002.vtc
@@ -0,0 +1,108 @@
+# $Id$
+
+test "handling stale_obj in vcl_miss() and vcl_fetch()"
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.X-VT-Stale == "false"
+        expect req.http.X-VT-Stale-Status == 503
+        expect req.http.X-VT-Stale-Hits == 0
+        expect req.http.X-VT-Stale-TTL == -1.000
+        expect req.http.X-VT-Stale-Grace == -1.000
+        expect req.http.X-VT-Stale-Last-Use == 0.000
+        expect req.http.X-VT-Stale-Keep == -1.000
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "1234567890"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.X-VT-Stale == "true"
+        expect req.http.X-VT-Stale-Proto == "HTTP/1.1"
+        expect req.http.X-VT-Stale-Status == 200
+        expect req.http.X-VT-Stale-Response == "Ok"
+        expect req.http.X-VT-Stale-Last-Modified == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.X-VT-Stale-TTL == 0.500
+        expect req.http.X-VT-Stale-Grace == 0.500
+        expect req.http.X-VT-Stale-Last-Use != 0.000
+        expect req.http.X-VT-Stale-Keep == 1.000
+        txresp -status 304
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.grace = 0.5s;
+            set beresp.ttl = 0.5s;
+            set beresp.keep = 1s;
+
+            if (stale_obj) {
+                set beresp.http.X-VT-Stale = "true";
+            }
+            else {
+                set beresp.http.X-VT-Stale = "false";
+            }
+            set beresp.http.X-VT-Stale-Proto = stale_obj.proto;
+            set beresp.http.X-VT-Stale-Status = stale_obj.status;
+            set beresp.http.X-VT-Stale-Response = stale_obj.response;
+            set beresp.http.X-VT-Stale-Hits = stale_obj.hits;
+            set beresp.http.X-VT-Stale-Last-Modified = stale_obj.http.Last-Modified;
+            set beresp.http.X-VT-Stale-TTL = stale_obj.ttl;
+            set beresp.http.X-VT-Stale-Grace = stale_obj.grace;
+            set beresp.http.X-VT-Stale-Last-Use = stale_obj.lastuse;
+            set beresp.http.X-VT-Stale-Keep = stale_obj.keep;
+        }
+
+        sub vcl_miss {
+            if (stale_obj) {
+                set bereq.http.X-VT-Stale = "true";
+            }
+            else {
+                set bereq.http.X-VT-Stale = "false";
+            }
+            set bereq.http.X-VT-Stale-Proto = stale_obj.proto;
+            set bereq.http.X-VT-Stale-Status = stale_obj.status;
+            set bereq.http.X-VT-Stale-Response = stale_obj.response;
+            set bereq.http.X-VT-Stale-Hits = stale_obj.hits;
+            set bereq.http.X-VT-Stale-Last-Modified = stale_obj.http.Last-Modified;
+            set bereq.http.X-VT-Stale-TTL = stale_obj.ttl;
+            set bereq.http.X-VT-Stale-Grace = stale_obj.grace;
+            set bereq.http.X-VT-Stale-Last-Use = stale_obj.lastuse;
+            set bereq.http.X-VT-Stale-Keep = stale_obj.keep;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-length == 10
+        expect resp.http.X-VT-Stale == "false"
+        expect resp.http.X-VT-Stale-Status == 503
+        expect resp.http.X-VT-Stale-Hits == 0
+        expect resp.http.X-VT-Stale-TTL == -1.000
+        expect resp.http.X-VT-Stale-Grace == -1.000
+        expect resp.http.X-VT-Stale-Last-Use == 0.000
+        expect resp.http.X-VT-Stale-Keep == -1.000
+} -run
+
+delay 1.1
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 10
+        expect resp.http.Content-Length == 10
+        expect resp.http.X-VT-Stale == "true"
+        expect resp.http.X-VT-Stale-Proto == "HTTP/1.1"
+        expect resp.http.X-VT-Stale-Status == 200
+        expect resp.http.X-VT-Stale-Response == "Ok"
+        expect resp.http.X-VT-Stale-Hits == 0
+        expect resp.http.X-VT-Stale-Last-Modified == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect resp.http.X-VT-Stale-TTL == 0.500
+        expect resp.http.X-VT-Stale-Grace == 0.500
+        expect resp.http.X-VT-Stale-Last-Use != 0.000
+        expect resp.http.X-VT-Stale-Keep == 1.000
+} -run
diff --git a/bin/varnishtest/tests/i00003.vtc b/bin/varnishtest/tests/i00003.vtc
new file mode 100644
index 0000000..809b317
--- /dev/null
+++ b/bin/varnishtest/tests/i00003.vtc
@@ -0,0 +1,146 @@
+# $Id$
+
+test "Test some anticipated use cases for conditional backend requests"
+
+## In vcl_miss(), it is possible to veto a conditional request by removing any
+## If-Modified-Since or If-None-Match header.
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -hdr "ETag: foo" \
+            -body "abcdefghijklmonpqrstuvwxyz"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect req.http.If-None-Match != "foo"
+        txresp -status 200 -body "abcdefghijklmonpqrstuvwxyz"
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+
+        sub vcl_miss {
+            unset bereq.http.If-Modified-Since;
+            unset bereq.http.If-None-Match;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-length == 26
+}
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 0
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Verify that if a client sends a conditional request to Varnish, then Varnish
+## can return a 304 response to the client after it got 304 from the backend
+
+server s2 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+} -start
+
+varnish v1 -vcl {
+        backend s2 {
+                .host = "${s2_addr}"; .port = "${s2_port}";
+        }
+
+        sub vcl_fetch {
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+} -start
+
+client c2 {
+        txreq -url "/foo" \
+            -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
+        rxresp
+        expect resp.status == 304
+}
+
+client c1 -run
+
+delay 1.1
+
+client c2 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s2 -wait
+varnish v1 -stop
+
+##
+## If stale_obj has a gzipped body, make sure it interacts correctly with clients
+##
+
+server s2 {
+        rxreq
+        expect req.http.accept-encoding == "gzip"
+        txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" -gzipbody FOO
+
+        rxreq
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+} -start
+
+varnish v1 -cliok "param.set http_gzip_support true" -vcl {
+        backend s2 {
+                .host = "${s2_addr}"; .port = "${s2_port}";
+        }
+
+        sub vcl_fetch {
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+            set beresp.keep = 1m;
+        }
+} -start
+
+client c1 {
+        txreq -hdr "Accept-encoding: gzip;q=0.1"
+        rxresp
+        expect resp.http.content-encoding == "gzip"
+        gunzip
+        expect resp.bodylen == "3"
+} -run
+
+delay 1.1
+
+client c2 {
+        txreq
+        rxresp
+        expect resp.bodylen == "3"
+        expect resp.http.content-encoding != "gzip"
+} -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
diff --git a/bin/varnishtest/tests/i00004.vtc b/bin/varnishtest/tests/i00004.vtc
new file mode 100644
index 0000000..0943f98
--- /dev/null
+++ b/bin/varnishtest/tests/i00004.vtc
@@ -0,0 +1,201 @@
+# $Id$
+
+test "Verify the semantics of keep (timeout for conditional requests)"
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "foo bar baz quux"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 -body "foo bar baz quux"
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.grace = 0s;
+            set beresp.ttl = 1s;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-length == 16
+        expect resp.http.Age == 0
+}
+
+varnish v1 -cli "param.set default_keep 1"
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 2.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Start a new varnish (now using the default default_keep),
+## and manipulate beresp.keep in VCL
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s1 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+    sub vcl_fetch {
+        set beresp.grace = 0s;
+        set beresp.ttl = 1s;
+        set beresp.keep = 1s;
+    }
+} -start
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 2.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Manipulate obj.keep in vcl_hit()
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s1 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+    sub vcl_fetch {
+        set beresp.grace = 0s;
+        set beresp.ttl = 1s;
+    }
+
+    sub vcl_hit {
+        set obj.keep = 1s;
+    }
+} -start
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 2.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Manipulate obj.keep in vcl_error()
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s1 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+    sub vcl_fetch {
+        set beresp.grace = 0s;
+        set beresp.ttl = 1s;
+    }
+
+    sub vcl_hit {
+        error 200 "Ok";
+    }
+
+    sub vcl_error {
+        set obj.keep = 1s;
+        return(deliver);
+    }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+}
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 2.1
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## req.keep sets an upper bound for all *.keeps in a session
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s1 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+    sub vcl_recv {
+        set req.keep = 0.5s;
+    }
+
+    sub vcl_fetch {
+        set beresp.grace = 0s;
+        set beresp.ttl = 1s;
+        set beresp.keep = 1s;
+    }
+} -start
+
+client c1 -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.6
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
diff --git a/bin/varnishtest/tests/i00005.vtc b/bin/varnishtest/tests/i00005.vtc
new file mode 100644
index 0000000..0bcac4f
--- /dev/null
+++ b/bin/varnishtest/tests/i00005.vtc
@@ -0,0 +1,147 @@
+# $Id$
+
+test "Verify interactions of ttl, keep, grace and bans"
+
+## Banned objects are not used for conditional requests
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "The quick brown fox jumps over the lazy dog."
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 -body "The quick brown fox jumps over the lazy dog."
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+        set beresp.grace = 0s;
+        set beresp.ttl = 1s;
+        set beresp.keep = 1m;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 44
+}
+
+client c1 -run
+
+delay 1.1
+
+varnish v1 -cli "ban.url \"/foo\""
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 0
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## If keep is set to non-zero, but then ttl is set to 0,
+## then the object is not used for conditional requests
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s2 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+    sub vcl_fetch {
+        set beresp.keep = 1m;
+        set beresp.ttl = 0s;
+    }
+} -start
+
+client c1 -run
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 0
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## If ttl is set to 0 but keep is then set to non-zero,
+## then the object is used for conditional requests
+## First test using beresp in vcl_fetch()
+
+server s2 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "The quick brown fox jumps over the lazy dog."
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+} -start
+
+varnish v1 -vcl {
+    backend s2 {
+            .host = "${s2_addr}"; .port = "${s2_port}";
+    }
+
+    # NB: return(deliver) necessary here, because default vcl_fetch() returns
+    # hit_for_pass if beresp.ttl <= 0
+    sub vcl_fetch {
+        set beresp.ttl = 0s;
+        set beresp.keep = 1m;
+        return (deliver);
+    }
+} -start
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 44
+} -run
+
+delay 0.5
+
+client c2 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s2 -wait
+varnish v1 -stop
+
+## Verify using obj.ttl in vcl_hit()
+
+server s2 -start
+
+varnish v1 -vcl {
+    backend s2 {
+            .host = "${s2_addr}"; .port = "${s2_port}";
+    }
+
+    sub vcl_hit {
+        set obj.ttl = 0s;
+        set obj.keep = 1m;
+    }
+} -start
+
+client c1 -run
+
+client c1 -run
+
+delay 0.5
+
+client c1 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
diff --git a/bin/varnishtest/tests/i00006.vtc b/bin/varnishtest/tests/i00006.vtc
new file mode 100644
index 0000000..87c6192
--- /dev/null
+++ b/bin/varnishtest/tests/i00006.vtc
@@ -0,0 +1,156 @@
+# $Id$
+
+test "Verify effects of ttl, keep and grace on expiration"
+
+## Verify that an object's lifetime in the cache is
+## obj.ttl + max(obj.grace, obj.keep)
+## First with grace < keep
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "fred garply waldo xyzzy"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 -body "fred garply waldo xyzzy"
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.ttl = 0.5s;
+            set beresp.grace = 0.5s;
+            set beresp.keep = 1s;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 23
+} -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 23
+        expect resp.msg == "Ok Not Modified"
+} -run
+
+delay 1.6
+
+client c3 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.msg == "Ok"
+} -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Now with keep < grace
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "fred garply waldo xyzzy"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 -body "fred garply waldo xyzzy"
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.ttl = 1s;
+            set beresp.grace = 1s;
+            set beresp.keep = 0.5s;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 23
+} -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 23
+        expect resp.msg == "Ok Not Modified"
+} -run
+
+delay 1.6
+
+client c3 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.msg == "Ok"
+} -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
+
+server s1 -wait
+varnish v1 -stop
+
+## Verify that req.keep sets an upper bound in the session
+
+server s1 -start
+
+varnish v1 -vcl {
+    backend s1 {
+            .host = "${s1_addr}"; .port = "${s1_port}";
+    }
+
+        sub vcl_recv {
+            set req.keep = 1s;
+        }
+
+        sub vcl_fetch {
+            set beresp.ttl = 1s;
+            set beresp.grace = 0s;
+            set beresp.keep = 2s;
+        }
+} -start
+
+client c1 -run
+
+delay 1.1
+
+client c2 -run
+
+delay 2.1
+
+client c3 -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 0
diff --git a/bin/varnishtest/tests/i00007.vtc b/bin/varnishtest/tests/i00007.vtc
new file mode 100644
index 0000000..487c0d0
--- /dev/null
+++ b/bin/varnishtest/tests/i00007.vtc
@@ -0,0 +1,129 @@
+# $Id$
+
+test "Passes through responses to backend conditionals to the client if status != 304 or 200"
+
+# Testing a sample from each of the Nxx status codes
+
+server s1 {
+        rxreq
+        expect req.url == "/foo"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "Varnish has poked you"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 304
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 201 -msg "Created" \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "Varnish has poked you"
+
+        # 3xx responses typically do not include Last-Modified or a body
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 301 -msg "Moved Permanently"
+
+        # Restore a cached object with Last-Modified
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "Varnish has poked you"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 400 -msg "Bad Request" \
+            -body "Varnish has poked you"
+
+        # Restore a cached object with Last-Modified
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since != "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 200 \
+    	    -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+            -body "Varnish has poked you"
+
+        rxreq
+        expect req.url == "/foo"
+        expect req.http.If-Modified-Since == "Thu, 26 Jun 2008 12:00:01 GMT"
+        txresp -status 500 -msg "Internal Server Error" \
+            -body "Varnish has poked you"
+} -start
+
+varnish v1 -vcl+backend {
+        sub vcl_fetch {
+            set beresp.ttl = 1s;
+            set beresp.grace = 0s;
+            set beresp.keep = 1s;
+        }
+} -start
+
+client c1 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 200
+        expect resp.bodylen == 21
+} -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 201
+        expect resp.msg == "Created"
+        expect resp.http.Last-Modified == "Thu, 26 Jun 2008 12:00:01 GMT"
+        expect resp.bodylen == 21
+} -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 301
+        expect resp.msg == "Moved Permanently"
+}  -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 400
+        expect resp.msg == "Bad Request"
+        expect resp.bodylen == 21
+}  -run
+
+delay 1.1
+
+client c1 -run
+
+delay 1.1
+
+client c2 {
+        txreq -url "/foo"
+        rxresp
+        expect resp.status == 500
+        expect resp.msg == "Internal Server Error"
+        expect resp.bodylen == 21
+}  -run
+
+varnish v1 -expect fetch_304 == 1
+varnish v1 -expect cond_not_validated == 4



More information about the varnish-commit mailing list