您的位置:首页 > 其它

关于get请求的缓存问题

2015-08-28 15:21 281 查看
关于浏览器使用get方法请求数据再次请求有缓存json不再请求

方法:

1 插入时间戳,使每次的请求的参数都不同

var getTimestamp = new Date().getTime();

url = url+”×tamp=”+getTimestamp;

2 插入随机数

var t=Math.random();

url = url+”&t=”+t;

3 请求时在请求头

xmlHttpRequest.setRequestHeader(“cache-control”,”no-cache”);

防止location缓存方法也同样适用。

elem.location.href = a.html+parseInt(Math.random()*1000);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: