cache-polyfill

1.0.1 • Public • Published

cache-polyfill

cache polyfill, Offline storage, Wraps IndexedDB, works without https/ssl

PWA builder! This is for you who don't have a ssl or need to support older browser.

Example Usage

import {Cache, CacheStorage, caches} from 'cache-polyfill'
// import 'whatwg-fetch'
 
// example usage:
caches.open('v1').then(function(cache) {
  return cache.addAll([
    '/asset/index.html',
    '/asset/star-wars-logo.jpg',
    '/asset/gallery/bountyHunters.jpg',
    '/asset/gallery/myLittleVader.jpg',
    '/asset/gallery/snowTroopers.jpg'
  ]);
})
 
const request = new Request('/asset/component.tpl')
caches.match(request).then(response => {
  return response || fetch(request).then(response => {
    caches.open('v1').then(cache =>
      cache.put(event.request, response)
    )
    return response.clone();
  })
})

Documentation and more example over at mozilla - Cache

/cache-polyfill/

    Package Sidebar

    Install

    npm i cache-polyfill

    Weekly Downloads

    110

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    225 kB

    Total Files

    18

    Last publish

    Collaborators

    • endless