sshuttle-gui/assets/sw.js

26 lines
594 B
JavaScript
Raw Normal View History

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 */
self.addEventListener('install', function (e) {
2021-07-09 16:12:48 -05:00
e.waitUntil(
caches.open(cacheName).then(function (cache) {
2021-07-09 16:12:48 -05:00
return cache.addAll(filesToCache);
})
);
});
/* Serve cached content when offline */
self.addEventListener('fetch', function (e) {
2021-07-09 16:12:48 -05:00
e.respondWith(
caches.match(e.request).then(function (response) {
2021-07-09 16:12:48 -05:00
return response || fetch(e.request);
})
);
});