Skip to content

Instantly share code, notes, and snippets.

@goofmint

goofmint/index.js

Created Aug 14, 2018
Embed
What would you like to do?
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