【ajax中ie浏览器缓存存问题解决方法】ajax中ie浏览器缓存存问题解决办法

时间:2017-09-11  来源:浏览器  阅读:

:在AJAX请求的链接中添加时间戳或随机数

总结三种方法

 代码如下


1.xmlhttp.setRequestHeader("Cache-Control","no-cache");

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

3.url += "×tamp="+new Date().getTime();

分析研究


在javascript发送的URL后加上t=Math.random(),如
href = URL+"&"+"t="+Math.random();
或 href = URL + "&" + "t="+ new Date().getTime();
:在XMLHttpRequest发送请求之前加上XMLHttpRequest.setRequestHeader("If-Modified-Since","0");

xhr.setRequestHeader("If-Modified-Since","0");
xhr.send();
.服务器端代码加入Response.setHeader("Cache-Control", "no-cache, must-revalidate");
.如果是用jQuery的话就简单了,直接设置cache为false就可以

html处理办法

 代码如下

 

程序的话我们以java为实例

 代码如下

response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);

【ajax中ie浏览器缓存存问题解决方法】ajax中ie浏览器缓存存问题解决办法

http://m.bbyears.com/bangongshuma/35500.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新