美文网首页
解决微信浏览器缓存问题,主要针对h5

解决微信浏览器缓存问题,主要针对h5

作者: 幻听86 | 来源:发表于2019-06-25 11:18 被阅读0次

微信浏览器处理缓存方式:

1.头部处理缓存信息。

                 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />

                  <meta http-equiv="Pragma" content="no-cache" />

                   <meta http-equiv="Expires" content="0" />

2.修改js或css文件时加上版本号信息。

                   <link href="css/app.css?v=20190625" rel="stylesheet">

                   <script type="text/javascript" src="js/app.js?v=20190625"></script>

3.跳转另一个页面最好封装一个方法增加随机数。(可以参考下边的方法)

/**

 *  清理缓存的方法

 * 1.如果url地址有?加&,如果没有加?并且增加随机数 

 */

function toNewPage(url){

     if (url.indexOf('?') >0) {

          url+="&"+Math.random();

     } else {

          url+="?"+Math.random();

     }

    window.location.href=url;

}

相关文章

网友评论

      本文标题:解决微信浏览器缓存问题,主要针对h5

      本文链接:https://www.haomeiwen.com/subject/wmctcctx.html