Skip to content

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

License

Notifications You must be signed in to change notification settings

jimmywarting/cache-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published