2021-07-09 16:12:48 -05:00
|
|
|
var cacheName = 'egui-template-pwa';
|
|
|
|
var filesToCache = [
|
|
|
|
'./',
|
|
|
|
'./index.html',
|
2022-10-01 08:21:24 -05:00
|
|
|
'./sshuttle_gui.js',
|
|
|
|
'./sshuttle_gui_bg.wasm',
|
2021-07-09 16:12:48 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
/* Start the service worker and cache all of the app's content */
|
2021-08-23 15:32:44 -05:00
|
|
|
self.addEventListener('install', function (e) {
|
2021-07-09 16:12:48 -05:00
|
|
|
e.waitUntil(
|
2021-08-23 15:32:44 -05:00
|
|
|
caches.open(cacheName).then(function (cache) {
|
2021-07-09 16:12:48 -05:00
|
|
|
return cache.addAll(filesToCache);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Serve cached content when offline */
|
2021-08-23 15:32:44 -05:00
|
|
|
self.addEventListener('fetch', function (e) {
|
2021-07-09 16:12:48 -05:00
|
|
|
e.respondWith(
|
2021-08-23 15:32:44 -05:00
|
|
|
caches.match(e.request).then(function (response) {
|
2021-07-09 16:12:48 -05:00
|
|
|
return response || fetch(e.request);
|
|
|
|
})
|
|
|
|
);
|
2022-08-19 10:41:46 -05:00
|
|
|
});
|