{"id":17137872,"url":"https://github.com/tower1229/ajax-cache","last_synced_at":"2025-07-07T01:32:33.471Z","repository":{"id":57175089,"uuid":"124024166","full_name":"tower1229/AJAX-Cache","owner":"tower1229","description":":tophat:The best jQuery-ajax-cache plugin","archived":false,"fork":false,"pushed_at":"2019-01-17T06:41:57.000Z","size":16,"stargazers_count":21,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-25T09:13:08.926Z","etag":null,"topics":["ajax","cache","jquery-plugin"],"latest_commit_sha":null,"homepage":"http://refined-x.com/AJAX-Cache/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tower1229.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-06T05:11:19.000Z","updated_at":"2023-11-07T12:48:06.000Z","dependencies_parsed_at":"2022-09-03T11:00:40.577Z","dependency_job_id":null,"html_url":"https://github.com/tower1229/AJAX-Cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tower1229%2FAJAX-Cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tower1229%2FAJAX-Cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tower1229%2FAJAX-Cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tower1229%2FAJAX-Cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tower1229","download_url":"https://codeload.github.com/tower1229/AJAX-Cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695300,"owners_count":21146952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajax","cache","jquery-plugin"],"created_at":"2024-10-14T20:08:10.140Z","updated_at":"2025-04-13T09:50:51.537Z","avatar_url":"https://github.com/tower1229.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"English | [中文](README_CN.md)\n\n# AJAX-Cache\n\n[![npm](https://img.shields.io/npm/v/ajax-cache.svg)](https://www.npmjs.com/package/@tower1229/AJAX-Cache) [![GitHub release](https://img.shields.io/github/release/tower1229/AJAX-Cache.svg)]() [![license](https://img.shields.io/github/license/tower1229/AJAX-Cache.svg)]()\n\n\u003e :tophat:The best jQuery-ajax-cache plugin\n\n## Introduction\n\nAJAX-Cache is a jQuery plug-in. It implements asynchronous request caching based on localStorage/sessionStorage, and provides two cache modes: snapshot and timer.\n\n## Install\n\n### npm\n\n`npm i ajax-cache  --save`\n\n### Download\n\nhttps://github.com/tower1229/AJAX-Cache\n\n## Usage\n\nYou only need to add a `localCache` configuration for jQuery.ajax ()\n\n### Open the snapshot cache\n\n```\n$.ajax({\n    url: \"http://rapapi.org/mockjsdata/9195/common/getRandom\",\n    dataType:'json',\n    localCache: 'snapshot',\n    success: function(res) {\n        if (res.snapshot) {\n            console.log('[snapshot] ' + res.data);\n        } else if (res.snapshootEqual) {\n            console.log('remote data is equal snapshot');\n        } else {\n            console.log('[remote data] ' + res.data);\n        }\n    }\n});\n```\n\n### Open the timing caching\n\n```\n$.ajax({\n    url: \"http://rapapi.org/mockjsdata/9195/common/getRandom\",\n    dataType:'json',\n    localCache: 5000,\n    success: function(res) {\n        console.log('\\n[Caching for 5 seconds] ' + res.data);\n    }\n});\n```\n\n### Scavenging caching\n\n```\n$.ajax({\n    url: \"http://rapapi.org/mockjsdata/9195/common/getRandom\",\n    dataType:'json',\n    localCache: false,\n    success: function(res) {\n    \tconsole.log('Cache has been cleared');\n        console.log(res.data);\n    }\n});\n```\n\n### Scavenging all caches\n\n```\n$.ajaxCache.clear();\n```\n\n### Configuration\n\n```\n$.ajaxCache.set({\n\tstorage: 'localStorage', \t\t//Storage mode, default \"localStorage\", optional \"sessionStorage\"\n\tcacheNamePrefix: '_ajaxcache'\t//Storage prefix, usually without modification\n});\n```\n\n## Live Example\n\nhttp://refined-x.com/AJAX-Cache/test/\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2017-present, [refined-x.com](http://refined-x.com)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftower1229%2Fajax-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftower1229%2Fajax-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftower1229%2Fajax-cache/lists"}