text: // This file is intentionally without code.
  // It's present so that service worker registration will work when serving from the 'app' directory.
  // The version of service-worker.js that's present in the 'dist' directory is automatically
  // generated by the 'generate-service-worker' gulp task, and contains code to precache resources.
  
  /* Set up files that will always be cached */
  const cacheName = 'v1';
  const cacheFiles = [
    './',
    'https://fonts.googleapis.com/css?family=Nunito',
    './index.html',
    './article.html',
    './styles/main.css',
    './scripts/main.min.js',
  ];
  
  self.addEventListener('install', function(e) {
    console.log('[ServiceWorker] Installed');
  
    e.waitUntil(
      caches.open(cacheName).then(function(cache) {
        console.log('[ServiceWorker] Caching cachefiles');
        return cache.addAll(cacheFiles);
      })
    );
  });
  
  self.addEventListener('activate', function(e) {
    console.log('[ServiceWorker] Activated');
  
    // Iterate through the cache and clear out old cachefiles
    e.waitUntil(
      caches.keys().then(function(cacheNames) {
        return Promise.all(cacheNames.map(function(thisCacheName){
          if (thisCacheName !== cacheName) {
            // console.log('[ServiceWorker] Removing Cached Files from ', thisCacheName);
            return caches.delete(thisCacheName);
          }
        }));
      })
    )
  });
  
  self.addEventListener('fetch', function(e) {
    e.respondWith(
      caches.match(e.request).then(function(response) {
        if (response) {
          console.log('[ServiceWorker] Found in cache :', e.request.url);
          console.log('[ServiceWorker] Response :', response);
          return response;
        }
  
        let requestClone = e.request.clone();
  
        fetch(requestClone)
          .then(function(response) {
            if (!response) {
              console.log('[ServiceWorker] no response from fetch');
              return response;
            }
            let responseClone = response.clone();
  
            caches.open(cacheName).then(function(cache) {
              cache.put(e.request, responseClone);
              return response;
            });
          }).catch(function(err) {
            console.error('[ServiceWorker] Errored out due to :', err);
          })
      })
    ); // end of respondWith
  });
  