[master] b470a65 When running with gzip support enabled, ignore "accept-encoding" in vary-matching. Varnish will adapt whatever we find to the clients abilities as necessary.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Jan 24 21:58:20 CET 2011
commit b470a6524ac0917b20889740dc4c276c1a0d8d55
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 24 20:57:15 2011 +0000
When running with gzip support enabled, ignore "accept-encoding" in
vary-matching. Varnish will adapt whatever we find to the clients
abilities as necessary.
diff --git a/bin/varnishd/cache_vary.c b/bin/varnishd/cache_vary.c
index 24770a3..9149df0 100644
--- a/bin/varnishd/cache_vary.c
+++ b/bin/varnishd/cache_vary.c
@@ -144,6 +144,24 @@ VRY_Match(const struct sess *sp, const unsigned char *vary)
while (*vary) {
+ if (params->http_gzip_support &&
+ !strcasecmp(H_Accept_Encoding, (const char*)vary)) {
+ /*
+ * If we do gzip processing, we do not vary on
+ * Accept-Encoding, because we want everybody to
+ * get the gzip'ed object, and varnish will gunzip
+ * as necessary. We implement the skip at check
+ * time, rather than create time, so that object
+ * in persistent storage can be used with either
+ * setting of http_gzip_support.
+ */
+ vary += *vary + 2;
+ l = vary[0] * 256 + vary[1];
+ vary += 2;
+ if (l != 0xffff)
+ vary += l;
+ continue;
+ }
/* Look for header */
i = http_GetHdr(sp->http, (const char*)vary, &h);
vary += *vary + 2;
diff --git a/bin/varnishtest/tests/e00025.vtc b/bin/varnishtest/tests/e00025.vtc
new file mode 100644
index 0000000..6d2e90c
--- /dev/null
+++ b/bin/varnishtest/tests/e00025.vtc
@@ -0,0 +1,26 @@
+# $Id$
+
+test "Test that esi+gzip correctly bypasses Vary: accept-encoding"
+
+server s1 {
+ rxreq
+ expect req.http.accept-encoding == gzip
+ txresp -hdr "Vary: Accept-encoding" -gzipbody {FOO}
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+ txreq -hdr "Accept-encoding: gzip"
+ rxresp
+ expect resp.http.content-encoding == gzip
+ expect resp.status == 200
+ gunzip
+ expect resp.bodylen == 3
+
+ txreq
+ rxresp
+ expect resp.http.content-encoding == resp.http.content-encoding
+ expect resp.status == 200
+ expect resp.bodylen == 3
+} -run
More information about the varnish-commit
mailing list