blob: 15a96f391b6338e062f15060c01d5370b2f58df5 [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) /* eslint no-undef : 0 */
.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) { /* eslint no-undef : 0 */
// Cache hit? return response else fetch it
return response || fetch(event.request); /* eslint no-undef : 0 */
}));
});