PWA 离线时 Lighthouse start_url 不响应 200

问题描述

在运行 Lighthouse 审核后,我收到与我的 PWA 的服务工作线程相关的以下错误

离线时 Start_url 不响应 200 start_url 确实响应了,但不是通过服务工作者响应。

我该如何解决这个问题!?我的服务人员如下:

const staticCacheName = 'site-static-v12.13';
const dynamicCache = 'dynamicCache-v12.13';
const assets = [
    '/',];

// install service event
self.addEventListener('install',evt => {
    // console.log('Service worker is installed');
    evt.waitUntil(
        caches.open(staticCacheName).then(cache => {
            console.log('caching shell assets');
            cache.addAll(assets);
        })
    );
});

// activate service worker
self.addEventListener('activate',evt => {
    // console.log('SW is activated');
    evt.waitUntil(
        caches.keys().then(keys => {
            return Promise.all(keys
                .filter(key => key !== staticCacheName)
                .map(key => caches.delete(key))
            )
        })
    );
});

// Fetch Events
self.addEventListener('fetch',evt => {
    // console.log('fetch event,evt');
    evt.respondWith(
        caches.match(evt.request).then(cacheRes => {
          return cacheRes || fetch(evt.request).then(fetchRes => {
              return caches.open(dynamicCache).then(cache => {
                  cache.put(evt.request.url,fetchRes.clone());
                  return fetchRes;
              })
          });
        })
    );
});

请注意,我的 manifest.json 文件也包含一个 "start_url": "/"

欢迎任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...