Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serviceWorker.js 1015B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. // TODO: Instance var/const for version control and cache list
  3. // NOTE: Registration
  4. if ('serviceWorker' in navigator) {
  5. // Register a service worker hosted at the root of the
  6. // site using the default scope.
  7. navigator.serviceWorker.register('/serviceWorker.js', {
  8. scope: '/'
  9. }).then(function (registration) {
  10. return console.log('Service worker registration succeeded: ', registration);
  11. }).catch(function (error) {
  12. // registration failed
  13. return console.log('Service worker registration failed: ', error);
  14. });
  15. } else {
  16. console.log('Service workers are not supported.');
  17. }
  18. // NOTE: Install and activate: Populating cache
  19. self.addEventListener('install', function (event) {
  20. event.waitUntil(
  21. caches.open('v1').then(function (cache) {
  22. return cache.addAll([
  23. '/',
  24. '/index.html',
  25. '/style.css'
  26. ]);
  27. })
  28. );
  29. });
  30. // NOTE: Fetch structure
  31. self.addEventListener('fetch', function(event) {
  32. });
  33. // NOTE: Activate structure <- TODO: Delete older cache versions