Home >Web Front-end >JS Tutorial >js clear browser cache
The content of this article is about js clearing browser cache. I share it with everyone here. It can also be used as a reference for friends in need. Let’s take a look together
<META HTTP-EQUIV="pragma" CONTENT="no-cache"><!-- 禁止浏览器从本地计算机的缓存中访问页面内容 --> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"><!-- 用于指定请求和响应遵循的缓存机制 --> <META HTTP-EQUIV="expires" CONTENT="0"><!-- 用于设定网页的到期时间,一旦网页过期,必须到服务器上重新传输; -->
The approach followed by Baidu at first, but it is not suitable for 360
去除静态html的缓存--动态引入js文件 动态引入js文件以及在js文件后边添加动态参数<script src="http://wechat.yiwang.com/appwxshare/js/share_test.js" type="text/javascript" ></script>
Code
<html><meta charset="utf-8" /><body> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> <script> window.onload=function(){ var script=document.createElement("script"); script.setAttribute("type", "text/javascript"); var num=Math.random(); var _url="http://wechat.yiwang.com/appwxshare/js/share_test.js?v="+num; script.setAttribute("src", _url); var heads = document.getElementsByTagName("head"); if(heads.length) { heads[0].appendChild(script); } } </script></body></html>
Related recommendations:
Understanding of object-oriented packaging objects in JS
The above is the detailed content of js clear browser cache. For more information, please follow other related articles on the PHP Chinese website!