GracefulCache
A Cache API wrapper with other offline storages supports.
Install
$ npm i chialab-graceful-cache --save
$ bower i chialab-graceful-cache --save
Polyfill
This library relies on Fetch API support. If your target may not support those specs, you can add the whatwg-fetch polyfill provided by GitHub.
Quick use
Cache a text file:
let url = '...';
GracefulCache.open('test', 1, k)
.then((cache) =>
cache.add(url)
.then(() => cache.match(url))
.then((response) => response.text())
.then((text) => {
console.log(text);
});
You can use this library as Cache API polyfill:
if (!self.caches) {
self.caches = GracefulCache;
}
Supported methods
Todo
- Support for all request methods.
- Support for options.
- Support Cache.matchAll