我有一个简单的网站,我试图Add To Homescreen在网站上运行。我使用Visual Studio进行编码然后将其托管在Azure中。
出于某种原因,每次我使用Lighthouse审核我的网站时,它都会一直给我 public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable value : values) {
sum += value.get();
}
// big 2
context.write(key, new IntWritable(sum));
}
。
我确保我的所有页面都是服务工作者缓存的。
我不确定它是Failures: Manifest start_url is not cached by a Service Worker.
还是我的start_url
问题。以下是我的代码。
service-worker
manifest.json
{
"short_name": "MY EXPERTS",
"name": "MYEXPERT",
"icons": [
{
"src": "Images/petronas_logo_192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "Images/petronas_logo_192.png",
"type": "image/png",
"sizes": "512x512"
}
],
"background_color": "#FFFFFF",
"theme_color": "#67BCFF",
"display": "standalone",
"start_url": "/Home/Index"
}
AddServiceWorker.js
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js').
then(function (registration) {
// Registration was successful``
console.log('ServiceWorker registration successful with scope: ',
registration.scope);
}).catch(function (err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
service-worker.json