var cacheName = 'hello-pwa';
var filesToCache = [
  '/',
  'index.html',
  'img/icon.png',
  'css/index.css',
  'css/bootstrap.min.css',
  'css/atlantis.min.css',
  'js/jquery.3.2.1.min.js',
  'js/bootstrap.min.js',
  'js/jquery.mask.min.js',
  'js/index.js',
  'js/beep-02.mp3',
  'js/render.js',
  'js/localSession.js',
  'js/actions.js',
  'js/main.js'
];

/* Start the service worker and cache all of the app's content */
self.addEventListener('install', function(e) {
  e.waitUntil(
    caches.open(cacheName).then(function(cache) {
      return cache.addAll(filesToCache);
    })
  );
  self.skipWaiting();
});

/* Serve cached content when offline */
self.addEventListener('fetch', function(e) {
  e.respondWith(
    caches.match(e.request).then(function(response) {
      return response || fetch(e.request);
    })
  );
});
