Remove resource caching from service worker

This commit is contained in:
Niels van Velzen 2023-10-16 16:14:09 +02:00
parent 4882d9c8cc
commit f7f546f15f
4 changed files with 5 additions and 1514 deletions

View file

@ -1,13 +1,5 @@
/* eslint-env serviceworker */
/* eslint-disable import/namespace,import/named */
import { skipWaiting, clientsClaim } from 'workbox-core';
import { precacheAndRoute } from 'workbox-precaching';
/* eslint-enable import/namespace,import/named */
skipWaiting();
clientsClaim();
function getApiClient(serverId) {
return Promise.resolve(window.connectionManager.getApiClient(serverId));
}
@ -44,9 +36,5 @@ self.addEventListener('notificationclick', function (event) {
event.waitUntil(executeAction(action, data, serverId));
}, false);
// Do not precache files when running with webpack dev server so live reload works as expected
if (!__WEBPACK_SERVE__) { // eslint-disable-line no-undef
// this is needed by the webpack Workbox plugin
/* eslint-disable-next-line no-restricted-globals,no-undef */
precacheAndRoute(self.__WB_MANIFEST);
}
/* eslint-disable-next-line no-restricted-globals -- self is valid in a serviceworker environment */
self.addEventListener('activate', () => self.clients.claim());