[Varnish] #801: duplicate Content-Length headers
Varnish
varnish-bugs at varnish-cache.org
Mon Oct 25 09:10:02 CEST 2010
#801: duplicate Content-Length headers
----------------------+-----------------------------------------------------
Reporter: Talisker | Owner: phk
Type: defect | Status: new
Priority: high | Milestone:
Component: varnishd | Version: 2.1.4
Severity: normal | Keywords:
----------------------+-----------------------------------------------------
Varnish is sending an HTTP response to the client with duplicate Content-
Length headers; most browsers ignore this, but recent versions of Chrome
get confused -- instead of a normal error page, Chrome gives the end user
a friendly "Error 346 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH):
Unknown error."
The problem can be seen on http://gamestar.de, http://jamendo.com, and
http://associated-press.net, among others (all of which reference Varnish
in their headers); I'm also running into the problem on a site I'm working
on, and can confirm that the duplicate Content-Length headers appear
regardless of browser (again, chrome being the only one that pukes).
Some info from my server:
Varnish 2.1.4 -> Apache 2.2 -> Django 1.2.3, all on a solo 64-bit Ubuntu
10.04 server. Varnish is a stock install from repo.varnish-cache.org.
Response headers coming from Apache 2.2 into Varnish:
{{{
HTTP/1.1 200 OK
Date: Mon, 25 Oct 2010 06:34:06 GMT
Server: Apache/2.2
Content-Encoding: gzip
Expires: Mon, 25 Oct 2010 06:34:06 GMT
Vary: Cookie,Accept-Encoding
ETag: "611e6876fefd686ed347255f3d7e7ab0"
Cache-Control: max-age=0
Set-Cookie: csrftoken=5be57c4df521b9f4ab1a634ee73e5ddf; Max-Age=31449600;
Path=/
Set-Cookie: sessionid=42c35dfe2903aa53dbf1d4d08b16e934; Path=/
Content-Length: 874
Last-Modified: Mon, 25 Oct 2010 06:34:06 GMT
Content-Type: text/html; charset=utf-8
}}}
...and, the headers for the same request as passed on to the client (note
the duplicate Content-Length headers):
{{{
HTTP/1.1 200 OK
Server: Apache/2.2
Content-Encoding: gzip
Expires: Mon, 25 Oct 2010 06:33:21 GMT
Vary: Cookie,Accept-Encoding
ETag: "90b96d56a557f90f5f73f958b79be9a3"
Set-Cookie: csrftoken=77c35d105a360f679aa7f7d5920d047a; Max-Age=31449600;
Path=/
Set-Cookie: sessionid=fb6a8daedbbe59f02b0395ef7a104343; Path=/
Content-Length: 875
Last-Modified: Mon, 25 Oct 2010 06:33:21 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 875
Date: Mon, 25 Oct 2010 06:33:21 GMT
X-Varnish: 726005028
Age: 0
Via: 1.1 varnish
Connection: keep-alive
}}}
The VCL in question:
{{{
# Default backend definition.
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_recv {
# normalize accept-encoding header
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
# unkown algorithm
remove req.http.Accept-Encoding;
}
}
# grace setting
set req.grace = 30s;
# ignore cookies on static files
if (req.url ~
"\.(js|css|html|xml|gif|jpg|jpeg|bmp|png|tiff|tif|img|tga|wmf|ico|svg|swf|mp3|mp4|m4a|ogg|mov|avi|wmv)$")
{
if (req.http.cookie) {
remove req.http.cookie;
}
}
# remove csrftoken cookies from GETs
if (req.http.cookie && req.request == "GET" && req.http.cookie ~
"csrftoken=") {
set req.http.cookie = regsub(req.http.cookie, "(^|; )
*csrftoken=[^;]+;? *", "\1");
if (req.http.cookie == "") {
remove req.http.cookie;
}
}
}
sub vcl_fetch {
if (beresp.http.Pragma ~ "no-cache" || beresp.http.Cache-Control ~
"(no-cache|no-store|private)") {
return(pass);
}
set beresp.grace = 1m;
}
sub vcl_pipe {
set req.http.connection = "close";
}
}}}
...and, finally, a trace from varnishlog:
{{{
11 SessionOpen c 192.168.110.1 60791 0.0.0.0:8100
11 ReqStart c 192.168.110.1 60791 888116555
11 RxRequest c GET
11 RxURL c /url/
11 RxProtocol c HTTP/1.1
11 RxHeader c Host: example.com:8100
11 RxHeader c Connection: keep-alive
11 RxHeader c Cache-Control: no-cache
11 RxHeader c Pragma: no-cache
11 RxHeader c Accept:
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
11 RxHeader c User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1;
en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.11
Safari/534.10
11 RxHeader c Accept-Encoding: gzip,deflate,sdch
11 RxHeader c Accept-Language: en-US,en;q=0.8
11 RxHeader c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
11 RxHeader c Cookie: csrftoken=199e18114d7c1b4d36656b30cd545e43;
sessionid=41eef12ba53b68962854ba9d4e90bcda
11 VCL_call c recv
11 VCL_trace c 1 9.5
11 VCL_trace c 2 9.9
11 VCL_trace c 3 10.9
11 VCL_trace c 4 10.13
11 VCL_trace c 5 11.13
11 VCL_trace c 9 21.5
11 VCL_trace c 10 24.9
11 VCL_trace c 15 29.1
11 VCL_trace c 22 3.5
11 VCL_trace c 23 3.9
11 VCL_trace c 24 3.28
11 VCL_trace c 25 3.52
11 VCL_trace c 26 4.9
11 VCL_trace c 27 5.13
11 VCL_trace c 29 8.5
11 VCL_trace c 30 9.1
11 VCL_trace c 31 43.5
11 VCL_trace c 32 43.9
11 VCL_trace c 33 44.9
11 VCL_trace c 34 44.13
11 VCL_trace c 36 48.13
11 VCL_trace c 37 51.5
11 VCL_trace c 38 51.9
11 VCL_trace c 46 61.5
11 VCL_trace c 47 61.9
11 VCL_trace c 50 65.5
11 VCL_trace c 51 65.9
11 VCL_trace c 52 65.35
11 VCL_trace c 53 67.9
11 VCL_return c pass
11 VCL_call c hash
11 VCL_trace c 57 87.5
11 VCL_trace c 58 88.9
11 VCL_trace c 59 89.9
11 VCL_return c hash
11 VCL_call c pass
11 VCL_trace c 56 83.5
11 VCL_return c pass
12 BackendOpen b default 127.0.0.1 44909 127.0.0.1 80
11 Backend c 12 default default
12 TxRequest b GET
12 TxURL b /url/
12 TxProtocol b HTTP/1.1
12 TxHeader b Host: example.com:8100
12 TxHeader b Pragma: no-cache
12 TxHeader b Accept:
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
12 TxHeader b User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1;
en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.11
Safari/534.10
12 TxHeader b Accept-Language: en-US,en;q=0.8
12 TxHeader b Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
12 TxHeader b Accept-Encoding: gzip
12 TxHeader b cookie: sessionid=41eef12ba53b68962854ba9d4e90bcda
12 TxHeader b X-Forwarded-For: 192.168.110.1
12 TxHeader b X-Varnish: 888116555
12 RxProtocol b HTTP/1.1
12 RxStatus b 200
12 RxResponse b OK
12 RxHeader b Date: Mon, 25 Oct 2010 06:47:28 GMT
12 RxHeader b Server: Apache/2.2
12 RxHeader b Content-Encoding: gzip
12 RxHeader b Expires: Mon, 25 Oct 2010 06:47:28 GMT
12 RxHeader b Vary: Cookie,Accept-Encoding
12 RxHeader b ETag: "a34a447a0fb119421cd136a3888bde5c"
12 RxHeader b Cache-Control: max-age=0
12 RxHeader b Set-Cookie:
csrftoken=9fedc77c05845a879d117e125e899e76; Max-Age=31449600; Path=/
12 RxHeader b Set-Cookie:
sessionid=41eef12ba53b68962854ba9d4e90bcda; Path=/
12 RxHeader b Content-Length: 875
12 RxHeader b Last-Modified: Mon, 25 Oct 2010 06:47:28 GMT
12 RxHeader b Content-Type: text/html; charset=utf-8
11 TTL c 888116555 RFC 0 1287989248 0 0 0 0
11 VCL_call c fetch
11 VCL_trace c 16 32.5
11 VCL_trace c 17 32.9
11 VCL_trace c 18 32.44
11 VCL_trace c 20 38.5
11 VCL_trace c 66 108.5
11 VCL_trace c 67 108.9
11 VCL_trace c 68 109.9
11 VCL_return c pass
11 ObjProtocol c HTTP/1.1
11 ObjStatus c 200
11 ObjResponse c OK
11 ObjHeader c Date: Mon, 25 Oct 2010 06:47:28 GMT
11 ObjHeader c Server: Apache/2.2
11 ObjHeader c Content-Encoding: gzip
11 ObjHeader c Expires: Mon, 25 Oct 2010 06:47:28 GMT
11 ObjHeader c Vary: Cookie,Accept-Encoding
11 ObjHeader c ETag: "a34a447a0fb119421cd136a3888bde5c"
11 ObjHeader c Set-Cookie:
csrftoken=9fedc77c05845a879d117e125e899e76; Max-Age=31449600; Path=/
11 ObjHeader c Set-Cookie:
sessionid=41eef12ba53b68962854ba9d4e90bcda; Path=/
11 ObjHeader c Content-Length: 875
11 ObjHeader c Last-Modified: Mon, 25 Oct 2010 06:47:28 GMT
11 ObjHeader c Content-Type: text/html; charset=utf-8
12 Length b 875
12 BackendReuse b default
11 VCL_call c deliver
11 VCL_trace c 73 118.5
11 VCL_return c deliver
11 TxProtocol c HTTP/1.1
11 TxStatus c 200
11 TxResponse c OK
11 TxHeader c Server: Apache/2.2
11 TxHeader c Content-Encoding: gzip
11 TxHeader c Expires: Mon, 25 Oct 2010 06:47:28 GMT
11 TxHeader c Vary: Cookie,Accept-Encoding
11 TxHeader c ETag: "a34a447a0fb119421cd136a3888bde5c"
11 TxHeader c Set-Cookie:
csrftoken=9fedc77c05845a879d117e125e899e76; Max-Age=31449600; Path=/
11 TxHeader c Set-Cookie:
sessionid=41eef12ba53b68962854ba9d4e90bcda; Path=/
11 TxHeader c Content-Length: 875
11 TxHeader c Last-Modified: Mon, 25 Oct 2010 06:47:28 GMT
11 TxHeader c Content-Type: text/html; charset=utf-8
11 TxHeader c Content-Length: 875
11 TxHeader c Date: Mon, 25 Oct 2010 06:47:28 GMT
11 TxHeader c X-Varnish: 888116555
11 TxHeader c Age: 0
11 TxHeader c Via: 1.1 varnish
11 TxHeader c Connection: keep-alive
11 Length c 875
11 ReqEnd c 888116555 1287989248.537992716 1287989248.602463961
0.000497580 0.062018871 0.002452374
11 SessionClose c EOF
11 StatSess c 192.168.110.1 60791 0 1 1 0 1 1 558 875
}}}
--
Ticket URL: <http://varnish-cache.org/trac/ticket/801>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list