javascript如何清除缓存

来自:互联网
时间:2021-04-11
阅读:

JavaScript清除缓存的方法:

1,在html里head区添加代码:

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-type" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>

2,清除临时缓存

<body onLoad="javascript:document.yourFormName.reset()">

3,jquery ajax清除浏览器缓存的两种方法:

1)、通过$.ajaxSetup 设置属性cache:false,让ajax不调用浏览的缓存。

jQuery.ajaxSetup ({cache:false})

2)、在ajax的url后加上随机串来避免浏览缓存,例如:$.ajax({url:'test.php?'+parseInt(Math.random()*100000)})缓存。

返回顶部
顶部