vue.js 开发单页面的微信公众号的时候,更新代码后,访问页面空白,刷新后正常的问题一般是缓存问题,有2个解决办法。
1、客户端添加缓存控制、缓存过期时间
如下代码,添加到vue项目中的 index.html
的 head
中
- <meta http-equiv="pragma" content="no-cache" />
- <meta http-equiv="content-type" content="no-cache, must-revalidate" />
- <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
- <meta http-equiv="expires" content="Wed, 26 Feb 2000 11:22:33 GMT"/>
2、nginx 服务器添加缓存控制
如下代码,添加到站点的nginx配置中
- location / {
- # 解决微信缓存页面配置
- autoindex on;
- add_header Cache-Control "no-store";
- expires -1;
- # 解决微信缓存页面配置 end
- }
完毕
相关评论 当前评论 2 条 [ 游客 2 | 博主 0 ]
这个真的管用吗?
@聪明勇敢有力气 目前测试管用