javascript - start_url does not respond with a 200 when offline: The start_url did respond, but not via a service worker. Lighth

I am creating a PWA that works offline with a service worker.Right now it works correctly, but there i

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 get this problem: start_url does not respond with a 200 when offline The start_url did respond, but not via a service worker.

How do I pass that audit, even if there are other audits that say that I have successfully installed a service worker?

My website is here: and the service worker is here: .js

Thanks in advance.

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 get this problem: start_url does not respond with a 200 when offline The start_url did respond, but not via a service worker.

How do I pass that audit, even if there are other audits that say that I have successfully installed a service worker?

My website is here: https://nariohtools. and the service worker is here: https://nariohtools./sw.js

Thanks in advance.

Share Improve this question edited Nov 22, 2020 at 15:12 prialgon asked Nov 22, 2020 at 14:10 prialgonprialgon 431 silver badge7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

The related code is here:

caches.open(CACHE_NAME).then((cache) => {
  return fetch(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;
}));

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744276717a4566365.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信