Skip to content

Commit

Permalink
😀
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jun 25, 2023
1 parent 9b927c8 commit 419064b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions packages/qwik-city/runtime/src/service-worker/cached-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export const cachedFetch = (
cache: Cache,
fetch: Fetch,
awaitingRequests: AwaitingRequests,
request: Request,
preloadResponse?: Promise<Response> | undefined
request: Request
) =>
new Promise<Response>((promiseResolve, promiseReject) => {
const url = request.url;
Expand Down Expand Up @@ -60,8 +59,7 @@ export const cachedFetch = (
} else {
// no cached response found or user didn't want to use the cache
// do a full network request
const responsePromise = preloadResponse ? preloadResponse : fetch(request);
return responsePromise.then(async (networkResponse) => {
return fetch(request).then(async (networkResponse) => {
if (networkResponse.ok) {
// network response was good, let's cache it
await cache.put(url, networkResponse.clone());
Expand Down
7 changes: 2 additions & 5 deletions packages/qwik-city/runtime/src/service-worker/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const setupServiceWorkerScope = (
ev.respondWith(
swScope.caches.open(qBuildCacheName).then((qBuildCache) => {
prefetchWaterfall(appBundles, qBuildCache, swFetch, url);
return cachedFetch(qBuildCache, swFetch, awaitingRequests, request, ev.preloadResponse);
return cachedFetch(qBuildCache, swFetch, awaitingRequests, request);
})
);
}
Expand Down Expand Up @@ -63,10 +63,7 @@ export const setupServiceWorkerScope = (
}
});

swScope.addEventListener('activate', (event) => {
// if (self.registration.navigationPreload) {
// event.waitUntil(self.registration.navigationPreload.enable());
// }
swScope.addEventListener('activate', () => {
(async () => {
try {
const qBuildCache = await swScope.caches.open(qBuildCacheName);
Expand Down

0 comments on commit 419064b

Please sign in to comment.