Last active
March 31, 2016 10:49
-
-
Save PhilJ/45a75e7a4742aed2b45e0c8fa0047d51 to your computer and use it in GitHub Desktop.
Use the new cache API to make the browser cache assets for offline functionality and register service worker to return cached assets.
This file contains 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
// register service worker | |
navigator.serviceWorker.register('service-worker-cache-images.js', { scope: './' }) | |
.then(navigator.serviceWorker.ready) | |
.then(function () { | |
console.log('service worker registered') | |
}) | |
.catch(function (error) { | |
console.log('error when registering service worker', error, arguments) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment