我们使用IBM HTTP服务器作为我们的Web服务器。每当请求发送到主页时,浏览器都会缓存除CSS之外的所有静态文件,如js或图像。
为什么要缓存JS文件,这些文件也是静态的但不是CSS?
以下是CSS的请求和响应标题:
Status Code:200 OK
**Request Headersview**
Accept:text/css,*/*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
DNT:1
If-Modified-Since:Thu, 14 Feb 2013 20:38:02 GMT
If-None-Match:"6b01-4d5b53c299e80"
Proxy-Connection:keep-alive
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.3 Safari/537.31
**Response Headersview**
Accept-Ranges:bytes
Age:0
Cache-Control:max-age=172800
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:5831
Content-Type:text/css
Date:Tue, 26 Feb 2013 23:50:59 GMT
ETag:"6b01-4d5b53c299e80"
Expires:Thu, 28 Feb 2013 23:50:59 GMT
Last-Modified:Thu, 14 Feb 2013 20:38:02 GMT
Proxy-Connection:Keep-Alive
Server:IBM_HTTP_Server
Vary:Accept-Encoding,User-Agent
Via:1.1 localhost.localdomain
这些是JS文件的标题,返回304 :
**Request Headersview**
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
DNT:1
If-Modified-Since:Thu, 14 Feb 2013 20:38:10 GMT
If-None-Match:"7bcc-4d5b53ca3b080"
Proxy-Connection:keep-alive
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.3 Safari/537.31
**Response Headersview**
Cache-Control:max-age=172800
Connection:Keep-Alive
Date:Tue, 26 Feb 2013 23:50:58 GMT
Etag:"7bcc-4d5b53ca3b080"
Expires:Thu, 28 Feb 2013 23:50:59 GMT
Proxy-Connection:Keep-Alive
Vary:Accept-Encoding,User-Agent
Via:1.1 localhost.localdomain