inventur/serviceWorker.js
2018-01-24 17:13:21 +01:00

37 lines
1010 B
JavaScript

var APP_SHELL_CACHE = "inventur_shell-v2";
var urlsToCache = [
'css/lib/materialize.min.css',
'js/lib/materialize.min.js',
'js/lib/accounting.min.js',
'js/lib/moment-with-locales.min.js',
'js/lib/jquery.min.js',
'js/lib/vue-dev.js',
'js/lib/vue.min.js',
'js/lib/vue-resource.min.js',
'fonts/Roboto/*',
'data/articles.json'
];
self.addEventListener('install', function(event){
event.waitUntil(
caches.open(APP_SHELL_CACHE)
.then(function(cache){
console.log("[Cache] opened: ", APP_SHELL_CACHE);
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', function(event){
event.respondWith(
caches.open(APP_SHELL_CACHE).then(function(cache) {
return fetch(event.request)
.then(function(response){
cache.put(event.request, response.clone());
return response;
});
})
);
});