blob: 72a926a504e8eeb9622738f637ba94d8350f2ef4 [file] [log] [blame]
// Note, these will be updated automatically at build time
var CACHE_VERSION = '%CACHE_VERSION%';
var CACHE_LIST = ['CACHE_VALUES'];
this.addEventListener('install', function(event) {
// Perform install steps
console.log("cordova service worker is installing.");
event.waitUntil(caches.open(CACHE_VERSION)
.then(function(cache) {
return cache.addAll(CACHE_LIST);
}));
});
this.addEventListener('activate', function(event) {
// Perform activate steps
console.log("cordova service worker is activated.");
});
this.addEventListener('fetch', function(event) {
console.log("cordova service worker : fetch : " + event.request.url);
event.respondWith(caches.match(event.request).then(function(response) {
// Cache hit? return response else fetch it
return response || fetch(event.request);
}));
});