google-chrome-devtools - jekyll + service worker 失败 : service worker does not successfully serve the manifest's start_url

标签 google-chrome-devtools jekyll service-worker workbox lighthouse

无法为 jekyll 驱动的项目站点设置 Service Worker,灯塔 拒绝 start_url值并给出错误 Unable to fetch start URL via service worker
app->manifest输出显示根 /
试过 ./index.html以及 - 相同的结果。有没有办法通过审核?

list .json:

{
  "name": "outcast",
  "short_name": "outcast",
  "icons": [
    {
      "src": "/assets/images/splsh192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "/assets/images/splsh512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "lang": "en-US",
  "display": "standalone",
  "background_color": "#131313",
  "theme_color": "#f62e1a",
  "start_url": "/",
  "serviceworker": {
   "src": "sw.js",
   "scope": "/",
   "update_via_cache": "none"
 }
}

sw.js

最佳答案

更换 fetch处理程序在 sw.js使用官方指南中的代码修复了该问题。仍在调试未定义的缓存

self.addEventListener('fetch', function(event) {
  event.respondWith(
    caches.match(event.request)
      .then(function(response) {
        // Cache hit - return response
        if (response) {
          return response;
        }
        return fetch(event.request);
      }
    )
  );
});

关于google-chrome-devtools - jekyll + service worker 失败 : service worker does not successfully serve the manifest's start_url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50710520/

相关文章:

javascript - 如何调试 Node.js 应用程序?

angular - 通过 devtools 控制台,为 Angular 应用程序断开特定选项卡的热重载

ruby - Liquid Exception - Jekyll 发球

google-cloud-messaging - Chrome推送通知中Service Worker中的GCM注册ID

javascript - 如何在 ServiceWorker 中获取自己的 URL 或主机名?

php - Laravel/PHP dd() 在 Chrome 开发者工具中显示非结构化数组

javascript - Chrome DevTools 在大数据 uri 上卡住

utf-8 - 我的 jekyll 网站无法构建 : Liquid Exception: incompatible character encodings

jekyll - Liquid 有 "does not contain"或 "not in array"运算符吗?

javascript - Django + 服务 worker : "a redirected response was used for a request whose redirect mode is not follow" error