123456789101112131415161718192021222324252627282930313233343536373839 |
- 'use strict';
-
- // TODO: Instance var/const for version control and cache list
-
- // NOTE: Registration
- if ('serviceWorker' in navigator) {
- // Register a service worker hosted at the root of the
- // site using the default scope.
- navigator.serviceWorker.register('/serviceWorker.js', {
- scope: '/'
- }).then(function (registration) {
- return console.log('Service worker registration succeeded: ', registration);
- }).catch(function (error) {
- // registration failed
- return console.log('Service worker registration failed: ', error);
- });
- } else {
- console.log('Service workers are not supported.');
- }
-
- // NOTE: Install and activate: Populating cache
- self.addEventListener('install', function (event) {
- event.waitUntil(
- caches.open('v1').then(function (cache) {
- return cache.addAll([
- '/',
- '/index.html',
- '/style.css'
- ]);
- })
- );
- });
-
- // NOTE: Fetch structure
- self.addEventListener('fetch', function(event) {
-
- });
-
- // NOTE: Activate structure <- TODO: Delete older cache versions
|