1

我们使用 IBM HTTP 服务器作为我们的 Web 服务器。每当向主页发送请求时,浏览器都会缓存除 CSS 之外的所有静态文件,例如 js 或图像。

为什么要缓存同样是静态但不是 CSS 的 JS 文件?

下面是 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

这些是返回 304 的 JS 文件的标头

**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
4

0 回答 0