sshuttle-gui/assets/sw.js

26 lines
600 B
JavaScript
Raw Normal View History

2021-07-09 16:12:48 -05:00
var cacheName = 'egui-template-pwa';
var filesToCache = [
'./',
'./index.html',
'./eframe_template.js',
'./eframe_template_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);
})
);
});