Cache control header and browser cache behaviours
Cache, Web June 30th, 2007
Conclusion
By grab the packet and analysis, I discovered that:
- When a broswer send a request to server while:
-
- without local cache
- brower cache disabled or cleaned up
- user request for “deep refresh”
The browser will send a HTTP request without any cache-control related headers (e.g. If-Modified-Since,
If-None-Match, Cache-Control)
- press “refresh” button means different for different browser
-
- Opera will “deep refresh” without consider local cache
- Firefox, IE will consider local cache unless user press “CTRL+F5″ to force “deep refresh”
Vey useful links for cache control and browser behaviors
- Explain of cache control in detail (very nice article! ) http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/
- The State of Browser Caching: http://www.mnot.net/blog/2006/05/11/browser_caching
- XMLHttpRequest caching: http://www.mnot.net/javascript/xmlhttprequest/cache.html
Tests results for each browsers
- use ethereal to grab the packet and analysis
Firefox 2.0.0.3:
#1: First request without cache
GET /7/692/809/d102c6510d49b9/sp.ask.com/sh/i/a10/p/logo_ask_x.png HTTP/1.1 Host: a692.g.akamai.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 Accept: image/png,*/*;q=0.5 Accept-Language: zh-cn,zh;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.0 200 OK Server: Apache/2.0.55 (Unix) Last-Modified: Mon, 11 Dec 2006 23:44:12 GMT ETag: "501c-be1ceb00" Accept-Ranges: bytes Content-Length: 20508 Content-Type: image/png Cache-Control: max-age=0 Expires: Tue, 22 May 2007 02:09:05 GMT Date: Tue, 22 May 2007 02:09:05 GMT Connection: keep-alive .PNG. ...
#2: with cache
GET /7/692/809/d102c6510d49b9/sp.ask.com/sh/i/a10/p/logo_ask_x.png HTTP/1.1 Host: a692.g.akamai.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5Accept-Language: zh-cn,zh;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Mon, 11 Dec 2006 23:44:12 GMT If-None-Match: "501c-be1ceb00" Cache-Control: max-age=0 HTTP/1.0 304 Not Modified Date: Tue, 22 May 2007 02:07:17 GMT Connection: keep-alive
#3: Press “refreh” button
same as #2
#4 press CTRL+F5 force a deep “refresh”
same as #1
#5: force no cache by disable cache
same as #1
H3.Opera 9.0
#1: empty cache request
GET /sh/i/a10/p/askx_logo_home.gif HTTP/1.1
User-Agent: Opera/9.00 (Windows NT 5.1; U; zh-cn)
Host: sp.ask.comAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1Accept-Language: en_US,en;q=0.9Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0Cookie: accepting=1; wz_uid=074159E941E886C853D1D5E429E169AE; ptid=3131|1; user=l=dir; tbe=1; ax=4; wz_sid=084E6B5F2B5B2688C3D1D5E429E16925; wz_scnt=8Cookie2: $Version=1
Connection: Keep-Alive, TETE: deflate, gzip, chunked, identity, trailers
HTTP/1.1 200 OK
Date: Tue, 22 May 2007 02:21:47 GMT
Server: Apache/2.0.55 (Unix)
Last-Modified: Mon, 18 Dec 2006 21:08:31 GMT
ETag: "fce-623c31c0"
Accept-Ranges: bytesContent-Length: 4046
Cache-Control: max-age=31536000
Expires: Wed, 21 May 2008 02:21:47 GMT
Connection: close
Content-Type: image/gif
GIF89a..{
.........
#2: request with cache
304, not modified.
#3: Press “refresh” button (opera always refresh when button pressed)
same as #1
#4: disable cache
same as #1
—
IE 7
#1: first request
GET /7/692/809/d102c6510d49b9/sp.ask.com/sh/i/a10/p/logo_ask_x.png HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */* Accept-Language: en-usUA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Host: a692.g.akamai.net Connection: Keep-Alive HTTP/1.0 200 OK Server: Apache/2.0.55 (Unix) Last-Modified: Mon, 11 Dec 2006 23:44:12 GMT ETag: "501c-be1ceb00"Accept-Ranges: bytesContent-Length: 20508 Content-Type: image/png Cache-Control: max-age=0Expires: Tue, 22 May 2007 02:28:39 GMT Date: Tue, 22 May 2007 02:28:39 GMT Connection: keep-alive .PNG. ....
#2: refresh with cache
GET /7/692/809/d102c6510d49b9/sp.ask.com/sh/i/a10/p/logo_ask_x.png HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */* Accept-Language: en-usUA-CPU: x86 Accept-Encoding: gzip, deflate If-Modified-Since: Mon, 11 Dec 2006 23:44:12 GMT; length=20508 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Host: a692.g.akamai.net Connection: Keep-Alive HTTP/1.0 304 Not Modified Content-Type: image/png Last-Modified: Mon, 11 Dec 2006 23:44:12 GMT ETag: "501c-be1ceb00" Cache-Control: max-age=0 Expires: Tue, 22 May 2007 02:29:36 GMT Date: Tue, 22 May 2007 02:29:36 GMT Connection: keep-alive
#3: press “refresh” button
same as #2
#4: press CTRL+F5 (force a clean fresh)
same as #1
Popularity: 62% [?]
About
Wow! Really helpful.. Thanks!
I’m currently building simple web crawler for my thesis.
I have to say, that I could not agree with you in 100% regarding o.us poetry, but it’s just my opinion, which could be wrong