cache-polyfill

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
cache-polyfill
921.0.15 years ago5 years agoMinified + gzip package size for cache-polyfill in KB

Readme

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