----JS缓存页面数据---
2018-01-02 17:29
176 查看
//简单设置JS缓存 //1. 将数据设置到缓存: //JsCache.set(key,value,expirs), expirs也可以不设置,默认是60秒 //读取缓存:JsCache._cacheData.key var JsCache = { _cacheEndTime: 0, //缓存截止时间 _cacheData: {}, //以JSON对象存储 _currTime: 0, //当前时间戳,是毫秒数 set: function(key,value,timeOut) { this._currTime = Date.parse(new Date()) / 1000; timeOut = arguments[2] ? arguments[2] : 60; this._cacheEndTime = this._currTime + timeOut; this._cacheData[key] = value; }, get: function(key) { this._currTime = Date.parse(new Date()) / 1000; if (this._cacheEndTime < this._currTime) { //过期了 this.del(key); return null; } else { return this._cacheData[key]; } }, del: function(key) { delete this._cacheData[key]; } };
可以做页面局部刷新
相关文章推荐
- 关于js处理ajax请求返回json数据时出现页面缓存的解决方案(适用于showdialog)
- js从后台获取数据时,防止页面缓存问题,url后加时间戳
- 页面的数据缓存,包括文字和图片
- 让页面不缓存js
- asp.net 使用驻留在页面中的Cache缓存常用可定时更新的数据
- 关于pjax 如何设置不缓存加载页面里面的js文件和不修改浏览器中的URL地址
- vue2.0 keep-alive 缓存页面数据 3ff0
- IE中由于缓存导致页面数据不能及时更新的解决办法
- JS获取页面数据并打印
- Niep.js - Web移动端无刷新页面切换 -- 页面数据加载
- iOS UIWebView加载本地HTML页面规避js、css的缓存
- 使用Dojo实现页面不刷新提交数据时避免前台缓存的方法
- 微信小程序开发-点击事件,获取元素id,页面传值 & 获取js里的数据
- 静态HTML页面不缓存js文件的方法
- js 下拉底部加载|滑轮滚动到页面底部ajax加载数据的实例
- 开发中遇到Js缓存问题。和页面会话级别的缓存。
- 无限轮播+网络请求+GridView展示数据+ImageLoader-SD卡缓存+点击轮播图跳转页面
- 使用jQuery或者原生js实现鼠标滚动加载页面新数据
- JS实现-页面数据无限加载
- 经典js代码 实现动态传值 实现动态页面传值 options动态显示数据