Skip to content

Instantly share code, notes, and snippets.

@laphilosophia
Created November 5, 2018 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laphilosophia/2b05d878259e54fea133cd7504eb9bb6 to your computer and use it in GitHub Desktop.
Save laphilosophia/2b05d878259e54fea133cd7504eb9bb6 to your computer and use it in GitHub Desktop.
Cache API
// https://alligator.io/js/cache-api/
if ('caches' in window) {
const cacheName = 'sample-caches'
const url = '/resource'
caches.open(cacheName).then(cache => {
return console.log(cache)
})
fetch(url).then(res => {
return caches.open(cacheName).then(cache => {
return cache.put(url, res)
})
})
caches.keys().then(keys => {
keys.map(key => console.log(key))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment