Skip to content

Instantly share code, notes, and snippets.

@paul
Created April 18, 2011 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul/925714 to your computer and use it in GitHub Desktop.
Save paul/925714 to your computer and use it in GitHub Desktop.

HTTP Client bug in Chrome (and Safari)

We have a resource, /clients, that serves up both html and a custom json flavor, ssjk1. We set the response Vary header to include Accept. If we first request the resource as sskj1 then sometime later as the normal browser Accept header (*/*), we should get html. However, Chrome (and Safari) make a conditional HTTP request with If-Modified-Since.

Chromium Issue

Webkit Issue

Chrome

get, accept sskj1

GET /clients HTTP/1.1
Accept-Charset: UTF-8,*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept: application/vnd.absperf.sskj1+json, application/vnd.absperf.ssmj1+json
Cache-Control: max-age=0
Connection: keep-alive
Cookie: ssbe_current_account=...
Host: core.ssbe.localhost
Origin: http://synops.ssbe.localhost
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16


HTTP/1.1 200 OK
Accept-Charset: UTF-8,*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept: application/vnd.absperf.sskj1+json, application/vnd.absperf.ssmj1+json
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1728000
Cache-Control: private, max-age=15, s-maxage=15
Connection: Keep-Alive
Content-Type: application/vnd.absperf.sskj1+json; charset=utf-8
Cookie: ssbe_current_account=...
Date: Mon, 18 Apr 2011 16:42:09 GMT
Keep-Alive: timeout=5, max=91
Last-Modified: Wed, 13 Apr 2011 20:14:13 GMT
Server: Apache/2.2.17 (Unix) mod_ss10.0.648.205 Safari/534.16
Set-Cookie: _core_session=...
Status: 200
Transfer-Encoding: chunked

get, accept /, erroneously includes If-* headers.

GET /clients HTTP/1.1
Accept-Charset: UTF-8,*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Connection: keep-alive
Cookie: ssbe_current_account=...
Host: core.ssbe.localhost
If-Modified-Since: Wed, 13 Apr 2011 20:14:13 GMT
If-None-Match: "06dfa5b0d1c64a0453b52c49721615dc"
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16


HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=15, s-maxage=15
Connection: Keep-Alive
Date: Mon, 18 Apr 2011 16:48:30 GMT
ETag: "383edebf0b7419be40272efc693efd78"
Keep-Alive: timeout=5, max=100
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 Phusion_Passenger/3.0.6
Set-Cookie: _core_session=...
Vary: Accept,Content-Type,Content-Encoding,Authorization,Cookie

Firefox

get sskj1

GET /clients HTTP/1.1
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-us,en;q=0.5
Accept: application/vnd.absperf.sskj1+json, application/vnd.absperf.ssmj1+json
Connection: keep-alive
Cookie: _core_session=...
Host: core.ssbe.localhost
Keep-Alive: 115
Origin: http://synops.ssbe.localhost
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0


HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Cache-Control: private, max-age=15, s-maxage=15
Connection: Keep-Alive
Connection: keep-alive
Content-Type: application/vnd.absperf.sskj1+json; charset=utf-8
Cookie: _core_session=...
Date: Mon, 18 Apr 2011 16:52:25 GMT
Keep-Alive: 115
Keep-Alive: timeout=5, max=96
Last-Modified: Wed, 13 Apr 2011 20:14:13 GMT
Origin: http://synops.ssbe.localhost
Referer: http://synops.ssbe.localhost/
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 Phusion_Passenger/t-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Set-Cookie: _core_session=...
Status: 200
Transfer-Encoding: chunked

get accept /, no conditional headers

GET /clients HTTP/1.1
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-us,en;q=0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Cookie: _core_session=...
Host: core.ssbe.localhost
Keep-Alive: 115
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0


HTTP/1.1 200 OK
Connection: Keep-Alive
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Cookie: _core_session=...
Date: Mon, 18 Apr 2011 16:52:53 GMT
Keep-Alive: 115
Keep-Alive: timeout=5, max=100
Last-Modified: Wed, 13 Apr 2011 20:14:13 GMT
Referer: http://synops.ssbe.localhost/
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 Phusion_Passenger/3.0.6
Status: 200
Transfer-Encoding: chunked
X-Powered-By: Phusion Passenger (mod_r

Safari

get, accept sskj1

GET /clients HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-us
Accept: application/vnd.absperf.sskj1+json, application/vnd.absperf.ssmj1+json
Connection: keep-alive
Cookie: _core_session=...
Host: core.ssbe.localhost
Origin: http://synops.ssbe.localhost
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1


HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Origin: http://synops.ssbe.localhost
Access-Control-Max-Age: 1728000
Cache-Control: private, max-age=15, s-maxage=15
Connection: Keep-Alive
Content-Type: application/vnd.absperf.sskj1+json; charset=utf-8
Date: Mon, 18 Apr 2011 17:50:44 GMT
ETag: "06dfa5b0d1c64a0453b52c49721615dc"
Keep-Alive: timeout=5, max=99
Last-Modified: Wed, 13 Apr 2011 20:14:13 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 Phusion_Passenger/3.0.6
Set-Cookie: _core_session=...
Status: 200
Transfer-Encoding: chunked
Vary: Accept,Content-Type,Content-Encoding,Authorization,Cookie
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.6
X-Runtime: 0.956038
X-UA-Compatible: IE=Edge

get, accept /, erroneously includes If-* headers.

GET /clients HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-us
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Connection: keep-alive
Cookie: _core_session=...
Host: core.ssbe.localhost
If-Modified-Since: Wed, 13 Apr 2011 20:14:13 GMT
If-None-Match: "06dfa5b0d1c64a0453b52c49721615dc"
Referer: http://synops.ssbe.localhost/
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1


HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=15, s-maxage=15
Connection: Keep-Alive
Date: Mon, 18 Apr 2011 17:51:30 GMT
ETag: "383edebf0b7419be40272efc693efd78"
Keep-Alive: timeout=5, max=100
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 Phusion_Passenger/3.0.6
Set-Cookie: _core_session=...
Vary: Accept,Content-Type,Content-Encoding,Authorization,Cookie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment