强制刷新HTML文档的浏览器缓存 [英] Force refresh of browser-cache for HTML document
问题描述
网站被意外缓存在浏览器中大约一个月,设置了Expires和max-age标头。
缓存资源是 text / html
和根 /
。
A website was accidentally cached in the browser for about a month with Expires and max-age headers set.
The cached resource is text/html
and the root /
.
新鲜度验证应按预期使用下一个请求中的If-Modified-Since
标头。但不知何故,很多IE用户(包括IE11)都没有获得新版本,因为浏览器没有提出请求。
The freshness validation should work as expected with the If-Modified-Since
header in the next request. But somehow a lot of IE users (incl. IE11) don't get the new version anymore, as the browser doesn't make the request.
很容易破产像CSS这样的资源的缓存,但如何为文档/网站本身做这个?我不能只改变URL。
It's easy to bust the cache for resources like CSS, but how to do this for the document/website itself? I can not just change the URL.
推荐答案
添加.htaccess或apache配置
Add in the .htaccess or apache config this
ExpiresActive on
ExpiresByType text/html "access plus 0 seconds"
取自 h5bp apache配置。如果您使用其他服务器软件,请查看所有 h5bp server-configs repo 以获取类似代码。
Taken from h5bp apache config. If you use some other server software, checkout all h5bp server-configs repo for similar code.
这篇关于强制刷新HTML文档的浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!