dominus

One damus client to rule them all
git clone git://jb55.com/dominus
Log | Files | Refs | README

sw.js (600B)


      1 var cacheName = 'egui-template-pwa';
      2 var filesToCache = [
      3   './',
      4   './index.html',
      5   './eframe_template.js',
      6   './eframe_template_bg.wasm',
      7 ];
      8 
      9 /* Start the service worker and cache all of the app's content */
     10 self.addEventListener('install', function (e) {
     11   e.waitUntil(
     12     caches.open(cacheName).then(function (cache) {
     13       return cache.addAll(filesToCache);
     14     })
     15   );
     16 });
     17 
     18 /* Serve cached content when offline */
     19 self.addEventListener('fetch', function (e) {
     20   e.respondWith(
     21     caches.match(e.request).then(function (response) {
     22       return response || fetch(e.request);
     23     })
     24   );
     25 });