微信浏览器取消缓存的方法

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、更新文件的时候,在引用css,js等文件的语句上加上一个版本号,就能有效防止浏览器一直使用缓存中的css,js

<link href="css/demo.css?v=201606131149" rel="stylesheet">

 

3、防止页面被缓存的方法,在URL后面添加随机参数,这样每次访问的都是不同的连接

window.location='xxx.html?_r='+Math.random();

 

posted @ 2016-06-13 11:56  web_liu  阅读(4363)  评论(0编辑  收藏  举报