chialab-graceful-cache

A Cache API wrapper with other offline storages supports.


Keywords
cache
License
MIT
Install
npm install chialab-graceful-cache@0.0.1

Documentation

GracefulCache

A Cache API wrapper with other offline storages supports.

Install

NPM

$ npm i chialab-graceful-cache --save

Bower

$ 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

Dev

Chialab es6-workflow Travis Code coverage

Sauce Test Status