web-dave / angular-pwa

0 stars 1 forks source link

Cache Static Content #4

Open web-dave opened 5 years ago

web-dave commented 5 years ago
web-dave commented 5 years ago

sw.js


const cachefiles = [
  'runtime-es2015........js',
  'runtime-es5........js',
  'polyfills-es2015........js',
  'polyfills-es5........js',
  'main-es2015........js',
  'main-es5........js',
  'styles.....css',
  '/',
  'index.html'
]
web-dave commented 5 years ago

sw.js


caches
     .open('angular-pwa')
     .then(cache => cache.addAll(cachefiles ))
     .then(() => self.skipWaiting())
web-dave commented 5 years ago

sw.js


self.addEventListener("fetch", e => {
// Static Content
 e.respondWith(
   caches.match(e.request)
   .then(response => response || fetch(e.request))
 );
});
web-dave commented 5 years ago

Next