Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created August 14, 2018 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/0500e7e7450a434ca306f33bafc6b4f8 to your computer and use it in GitHub Desktop.
Save goofmint/0500e7e7450a434ca306f33bafc6b4f8 to your computer and use it in GitHub Desktop.
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