diff --git a/.eslintignore b/.eslintignore index 1028da0c658..e46b14bd09c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -18,6 +18,7 @@ scripts/**/* **/server/**/*.js *.tsbuildinfo packages/docs/api/**/* +packages/docs/public/repl/bundled/**/* packages/docs/src/routes/examples/apps/**/* packages/docs/src/routes/playground/app/**/* packages/docs/src/routes/tutorial/**/* diff --git a/packages/qwik/src/prefetch-service-worker/setup.ts b/packages/qwik/src/prefetch-service-worker/setup.ts index e48ca70e6a9..0f0fc8e9654 100644 --- a/packages/qwik/src/prefetch-service-worker/setup.ts +++ b/packages/qwik/src/prefetch-service-worker/setup.ts @@ -4,6 +4,17 @@ import { createState, type SWState } from './state'; export const setupServiceWorker = (swScope: ServiceWorkerGlobalScope) => { const swState: SWState = createState(swScope.fetch.bind(swScope), new URL(swScope.location.href)); + let cacheTimeout: any; + swState.$getCache$ = () => { + if (swState.$cache$) { + return swState.$cache$; + } + clearTimeout(cacheTimeout); + setTimeout(() => { + swState.$cache$ = null; + }, 5000); + return swScope.caches.open('QwikBundles'); + }; swScope.addEventListener('fetch', (ev) => { const request = ev.request; if (request.method === 'GET') { @@ -17,7 +28,9 @@ export const setupServiceWorker = (swScope: ServiceWorkerGlobalScope) => { swState.$msgQueue$.push(ev.data); drainMsgQueue(swState); }); - swScope.addEventListener('install', () => swScope.skipWaiting()); + swScope.addEventListener('install', () => { + swScope.skipWaiting(); + }); swScope.addEventListener('activate', (event) => { let cacheTimeout: any; swState.$getCache$ = () => {