jQuery AJAX 缓存插件 jquery-ajax-cache

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-03 12:44:31

软件介绍

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

引入

<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src='../dist/jquery-ajax-cache.js'></script>

使用

全局配置

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

简单使用

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

自定义

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

本文地址:https://codercto.com/soft/d/22567.html

Linux Device Drivers

Linux Device Drivers

Jonathan Corbet、Alessandro Rubini、Greg Kroah-Hartman / O'Reilly Media / 2005-2-17 / USD 39.95

Device drivers literally drive everything you're interested in--disks, monitors, keyboards, modems--everything outside the computer chip and memory. And writing device drivers is one of the few areas ......一起来看看 《Linux Device Drivers》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具