Created
November 5, 2018 12:09
-
-
Save laphilosophia/2b05d878259e54fea133cd7504eb9bb6 to your computer and use it in GitHub Desktop.
Cache API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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