SHARE
TWEET

Untitled

a guest Aug 24th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var cacheName = 'v1.0';
  2.  
  3. var cacheAssets = [
  4.     'index.html',
  5.     'about.html',
  6.     '/js/main.js',
  7.     '/css/style.css'
  8. ]
  9.  
  10. // installation
  11. self.addEventListener('install', e => {
  12.       console.log('Service Worker: Installed');
  13.       e.waitUntil(
  14.             caches
  15.               .open(cacheName)
  16.               .then(cache => {
  17.                 console.log('Service Worker: Caching Files');
  18.                 cache.addAll(cacheAssets);
  19.               })
  20.               .then(() => self.skipWaiting())
  21.           );
  22.  
  23. });    
  24.  
  25. // activation
  26. self.addEventListener('activate', e => {
  27.     console.log('Service Worker: Installed');
  28. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top