
const CACHE = 'atulya-pwa-v1';
const ASSETS = [
  '/pwa/index.html',
  '/pwa/manifest.json',
  '/pwa/assets/js/pwa_app.js',
  '/pwa/assets/js/pwa_sw_register.js',
  '/pwa/assets/css/pwa_core.css'
];

self.addEventListener('install', event => {
  event.waitUntil(caches.open(CACHE).then(cache => cache.addAll(ASSETS)));
  self.skipWaiting();
});

self.addEventListener('activate', event => {
  event.waitUntil(self.clients.claim());
});

self.addEventListener('fetch', event => {
  event.respondWith(caches.match(event.request).then(resp => resp || fetch(event.request)));
});
