Versions
Description
I implemented the service-worker using ng add @angular/pwa --project [app]
and Lighthouse would recognise the web-app as a PWA.
Suddenly, after one deploy to Firebase hosting the "install" notification wasn´t popping up, so I checked the dev-console.
The manifest was still showing up as usual:
But nothing was being cached:
When running a Lighthouse-Audit, I get following error:
start_url does not respond with a 200 when offline
ngsw-config.json
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
manifest.webmanifest
{
"name": "App",
"short_name": "App",
"theme_color": "#5787b2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
So I found the solution to my problem in this comment to a similar problem: https://stackoverflow.com/a/61152966/8581106
In app.module.ts
add registrationStrategy: 'registerImmediately'
to the registration of the ServiceWorker like this:
ServiceWorkerModule.register('ngsw-worker.js', { enabled: env.production, registrationStrategy: 'registerImmediately' }),