微信内置浏览器总是缓存网页内容解决思路

2023 年 10 月 29 日 1424 点热度 2 人点赞 0 条评论

1. 页面引用的静态资源增加版本号信息

比如旧 xx.js?version=1.0 新 xx.js?version=2.0

2. 在页面 html 头部添加如下 head

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1970 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

3. 如果有 nginx 的话,直接加标头告诉浏览器不缓存
add_header Cache-Control no-cache;
add_header Cache-Control private;

 

Gcod

人生若只如初见,何事秋风悲画扇

文章评论