Skip to content Skip to sidebar Skip to footer

Start_url Does Not Respond With A 200 When Offline: The Start_url Did Respond, But Not Via A Service Worker. Lighthouse Audit Problem

I am creating a PWA that works offline with a service worker. Right now it works correctly, but there is a problem in Lighthouse Audit. When I run Lighthouse, in the PWA section I

Solution 1:

The related code is here:

caches.open(CACHE_NAME).then((cache) => {
  returnfetch(evt.request)

You are opening the cache but you're not using the cached response and the request is forwarded to the network:

Use something like this instead:

caches.open(CACHE_NAME).then(cache => {
  return cache.match(evt.request).then(cacheResponse => cacheResponse || fetch(evt.request).then(networkResponse => {
  cache.put(evt.request, networkResponse.clone());
  return networkResponse;
}));

Solution 2:

Just in case you struggle with this, there is a bug in Lighthouse that has been fixed in Chrome version 89. https://github.com/antfu/vite-plugin-pwa/issues/20#issuecomment-773019940

Post a Comment for "Start_url Does Not Respond With A 200 When Offline: The Start_url Did Respond, But Not Via A Service Worker. Lighthouse Audit Problem"