可能重复:
Cache Control fails
我目前正在使用:
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
和
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
然而它仍然缓存
答案 0 :(得分:5)
您还可以添加Pragma: no-cache。并且确保Last-Modified
在过去已经足够了:客户端和服务器之间的一些小时钟偏差可能会诱使客户认为它有一个新版本的文档;例如,使用Tue, 15 Nov 1994 12:45:26 GMT
。并且还添加了Expires标题,其中包含过去的日期。
答案 1 :(得分:1)
我通常在我的.htaccess
中添加它<filesMatch "\.(js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
修改filesMatch以添加其他扩展程序......
答案 2 :(得分:0)
将时间戳添加到每个URI的末尾,浏览器不会从缓存中检索它(因为它将在下次加载时使用另一个URI)