Created
August 14, 2018 14:17
-
-
Save goofmint/0500e7e7450a434ca306f33bafc6b4f8 to your computer and use it in GitHub Desktop.
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
var urlsToCache = [ | |
'/', | |
'/bower_components/jquery/dist/jquery.min.js', | |
'/bower_components/hifive/h5.js', | |
'/bower_components/hifive/h5.css', | |
'/bower_components/hifive/ejs-h5mod.js', | |
'/ncmb.min.js', | |
'/app.js' | |
]; | |
self.addEventListener('install', function(event) { | |
return install(event); | |
}); | |
self.addEventListener('message', function(event) { | |
return install(event); | |
}); | |
const install = (event) => { | |
return event.waitUntil( | |
caches.open(CACHE_NAME) | |
.then(function(cache) { | |
urlsToCache.map(url => { | |
return fetch(new Request(url)).then(response => { | |
return cache.put(url, response); | |
}); | |
}) | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment