jquery-ajax-cache jQuery AJAX 缓存插件开源项目

我要开发同款
匿名用户2015年12月17日
159阅读

技术信息

开源地址
https://github.com/WQTeam/jquery-ajax-cache
授权协议
MIT

作品详情

jquery-ajax-cache是jQuery插件——利用‘localStorage’和‘sessioStorage’对jQueryAJAX请求进行缓存。

引入

<script src="../ode_modules/jquery/dist/jquery.js"></script><script src='../dist/jquery-ajax-cache.js'></script>使用

全局配置

$ajaxCache.cofig({ cacheValidate: fuctio (res) { //选填,配置全局的验证是否需要进行缓存的方法,“全局配置” 和 ”自定义“,至少有一处实现cacheValidate方法 retur res.state === 'ok';    },    storageType: 'localStorage', //选填,‘localStorage’ or 'sessioStorage', 默认‘localStorage’ timeout: 60 * 60, //选填, 单位秒。默认1小时 });

简单使用

$.ajax({    ajaxCache: true // “全局配置” 和 ”自定义“,至少有一处实现cacheValidate方法 /*  others...  */ });

自定义

$.ajax( // 此处的参数会覆盖‘全局配置’中的设置 ajaxCache: { cacheValidate: fuctio (res) { //选填,配置全局的验证是否需要进行缓存的方法, “全局配置” 和 ”自定义“,至少有一处实现cacheValidate方法 retur res.state === 'ok' && res.code ==='200';        },        storageType: 'localStorage', //选填,‘localStorage’ or 'sessioStorage', 默认‘localStorage’ timeout: 60 * 60, //选填, 单位秒。默认1小时 }});

功能介绍

jquery-ajax-cache 是 jQuery 插件——利用‘localStorage’ 和 ‘sessionStorage’ 对 jQuery AJAX 请求进行缓存。 引入
<sc...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论