aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-09-30 17:56:23 +0200
committerNoah Loomans <noahloomans@gmail.com>2016-09-30 17:56:23 +0200
commite61d32f93511833efef972a50a7fd7a9b4eec78d (patch)
treeb1bdbfd2359b246974a726ebd802a64ebfe84dab /public
parentae1f968de09f7952b5b4bad369255a0a60cb81b8 (diff)
add offline support
Diffstat (limited to 'public')
-rw-r--r--public/sw.js31
1 files changed, 31 insertions, 0 deletions
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)