我一直在寻找解决方案,但到目前为止还没有。我在Node.js / Express中动态呈现HTML页面,通过SHA256哈希HTML字符串生成ETag,并通过nginx发送页面。出于某种原因,Google Chrome不会缓存该页面或为之前的ETag发送“If-None-Match”标题。
以下是我的请求和回复标题:
请求:
GET / HTTP/1.1
Host: dev.logan.oikoi.co
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.82 Safari/537.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: km_ai=Q%2FR9nmmebaNLthhixes8jxMubzQ%3D; km_uq=; kvcd=1346083163009; km_vs=1; km_lv=1346083163
响应:
HTTP/1.1 200 OK
Server: nginx/1.2.3
Date: Sun, 26 Aug 2012 06:20:46 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: Express
Cache-Control: public, max-age=0, must-revalidate, proxy-revalidate
Expires: Thu, 01 Jan 1970 00:00:00 GMT
ETag: "2e26404f4306e4d2a7c821f537aa3e714d655d260462f8a7fdd9f0a8ad501900"
Set-Cookie: connect.sid=rPrRyvqf3LhbilN0syPU3htr.776UPuqojSyF1YgS0AFcyac4qQtv%2FXF9TFSHQ96p6e8; path=/; expires=Sun, 26 Aug 2012 10:20:46 GMT; httpOnly; secure
Content-Encoding: gzip
编辑:我在最初的帖子中忘了提及,但Firefox没有问题缓存页面。
答案 0 :(得分:1)
您的回复有这些标题 -
Cache-Control:public,max-age = 0,must-revalidate,proxy-revalidate
到期:周一,1970年1月1日00:00:00 GMT
删除这些标题,你应该很好。
仅供参考: