Last active
May 3, 2018 07:43
-
-
Save deanhume/81960f702ceab4f90725 to your computer and use it in GitHub Desktop.
A Service Worker that adds an offline page to cache
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
'use strict'; | |
var cacheVersion = 1; | |
var currentCache = { | |
offline: 'offline-cache' + cacheVersion | |
}; | |
const offlineUrl = 'offline-page.html'; | |
this.addEventListener('install', event => { | |
event.waitUntil( | |
caches.open(currentCache.offline).then(function(cache) { | |
return cache.addAll([ | |
'./img/offline.svg', | |
offlineUrl | |
]); | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment