From e61d32f93511833efef972a50a7fd7a9b4eec78d Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Fri, 30 Sep 2016 17:56:23 +0200 Subject: add offline support --- public/sw.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 public/sw.js (limited to 'public/sw.js') diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..1168c93 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,31 @@ +/* global importScripts toolbox self */ + +// random string: CHfHo0GjMJAoOC + +(global => { + 'use strict' + + // Load the sw-toolbox library. + importScripts('/components/sw-toolbox/sw-toolbox.js') + + // Ensure that our service worker takes control of the page as soon as possible. + global.addEventListener('install', event => event.waitUntil(global.skipWaiting())) + global.addEventListener('activate', event => event.waitUntil(global.clients.claim())) + + toolbox.precache([ + '/', + '/hello', + '/untisinfo.css', + '/javascripts/bundle.js', + '/stylesheets/style.css', + '/stylesheets/hello.css' + ]) + + toolbox.router.get('/', toolbox.cacheFirst) + toolbox.router.get('/hello', toolbox.cacheFirst) + + toolbox.router.get('/javascripts/bundle.js', toolbox.cacheFirst) + toolbox.router.get('/stylesheets/*', toolbox.cacheFirst) + toolbox.router.get('/untisinfo.css', toolbox.cacheFirst) + toolbox.router.get('/meetingpointProxy/*', toolbox.networkFirst) +})(self) -- cgit v1.1