Google chrome devtools 杰基尔+;服务工作程序失败:服务工作程序未成功提供清单';s start_url
无法为jekyll供电项目站点设置服务人员,Lighthouse拒绝Google chrome devtools 杰基尔+;服务工作程序失败:服务工作程序未成功提供清单';s start_url,google-chrome-devtools,jekyll,service-worker,workbox,lighthouse,Google Chrome Devtools,Jekyll,Service Worker,Workbox,Lighthouse,无法为jekyll供电项目站点设置服务人员,Lighthouse拒绝start\u url值并给出错误无法通过服务人员获取启动url 输出显示根/ 也尝试了/index.html-同样的结果。有办法通过审核吗 manifest.json: { "name": "outcast", "short_name": "outcast", "icons": [ { "src": "/assets/images/splsh192.png", "type": "
start\u url
值并给出错误无法通过服务人员获取启动url
输出显示根/
也尝试了/index.html
-同样的结果。有办法通过审核吗
manifest.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
处理程序,修复了该问题。仍在调试未定义的缓存
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);
}
)
);
});
你可以这样试试。我也有类似的问题:
self.addEventListener("fetch", function(event) {
event.respondWith(
fetch(event.request).catch(function(error) {
console.log(
"[Service Worker] Network request Failed. Serving content from cache: " +
error
);
//Check to see if you have it in the cache
//Return response
//If not in the cache, then return error page
return caches
.open(
"https://your.website"
)
.then(function(cache) {
return cache.match(event.request).then(function(matching) {
var report =
!matching || matching.status == 404
? Promise.reject("no-match")
: matching;
return report;
});
});
})
);
});
您在service worker中的
fetch
处理程序中有错误。您可以通过打开Chrome DevTools加载您的站点,然后启用脱机来查看它。@abraham控制台在2-3次重新加载后变为绿色,您也无法理解这一点。用作参考