解决浏览器缓存问题的三个解决方法

1.使用meta标签设置缓存机制

<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=202003041049" rel="stylesheet">

3.在URL后面添加随机参数,来辨别是不同的网址页面 这样每次访问的都是不同的链接

window.location='xxx.html?_r='+Math.random();
发布了62 篇原创文章 · 获赞 33 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq_37588752/article/details/104649031