强制刷新HTML文档的浏览器缓存

编程入门 行业动态 更新时间:2024-10-24 16:21:06
本文介绍了强制刷新HTML文档的浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

网站被意外缓存在浏览器中大约一个月,设置了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文档的浏览器缓存

本文发布于:2023-10-31 19:08:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547007.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   浏览器   文档   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!