防止index.html被浏览器缓存

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Expires" content="0">

1.服务器设置,nginx 配置如下:

location = /index.html {
add_header Cache-Control "no-cache, no-store";
}

2.md5勾选打包时候注意,不放入到build-templates\web-mobile的'config.js'文件,打包才不会生成md5后缀'config.c69ee.js'。
3.动态更改src的路径<script src="config.js" charset="utf-8"></script>也可以写成

  <script>
    var config = document.createElement('script');
    config.src = 'config.js';
    document.body.appendChild(config);
  </script>

https://www.zhihu.com/question/20790576

标签: none

添加新评论