关于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);
方法:
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);
相关文章推荐
- [Linux]查看启动信息方法
- iOS监听 网络信号变化
- UIImagePickerController拍照与摄像
- LeetCode-Distinct Subsequences
- Hibernate关联之一对一主键双向关联
- itertools模块
- 必须知道的八大种排序算法【java实现】(三) 归并排序算法、堆排序算法详解
- WebSocket学习
- docker问题笔记
- 现Linux发行版分类
- BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Applic
- 获取bitmap的大小
- 6.Dockerfile
- Linux学习笔记-----Linux服务管理----RPM服务管理---基于xinetd服务的服务管理
- [机器学习实战]-决策树
- Android修改输入法Enter的文本
- 词Ci首页效果实现介绍及源码分享
- 测试一下
- Java中的可变参数以及foreach语句
- 循环编辑文件夹IBMEmptorisSSM-WSDL 下面的所有的wsdl文件到 d盘的wsdlSource下