admin管理员组文章数量:1534187
问题场景:
1.线上部署nginx直接指向前端文件路径,nginx核心配置如下:
location /front/ {
try_files $uri $uri/ /front/index.html;
root /root/html/front;
}
2.前端每次发布新版时,通过微信浏览器访问原来链接 www.front/front/ 总是旧版代码,缓存时间很久。对发版造成严重影响
分析原因:
因为微信浏览器缓存了www.front/front/ 目录下的index.html,css文件,js文件,非常顽固。
解决方案:
1.改变访问链接www.front/front/?v=1123,这种方案线上环境基本不可行,只能在测试环境使用,因为用户端访问链接大部分情况都很难控制,不能通知所有用户去访问新链接
2.修改nginx配置,设置www.front/front/ 不缓存,nginx配置如下
location /front/ {
try_files $uri $uri/ /front/index.html;
root /root/html/front;
#kill 缓存
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
版权声明:本文标题:vue.js 微信浏览器缓存入口页面index.html问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726870349a1087808.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论