I want to make a PWA app with Angular 19 that is available offline. I followed the official documentation to install the ServiceWorker. But when I simulate the offline status in the browser, the app is not available. I have tried running it with ng serve --configuration=production or with npx http-server -p 8080 -c-1 dist/browser but it didn't change anything.
The worker is registered like this:
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes), provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
}),
],
};
I have also tried registerImmediately:30000, didn't help either.
Is there anything else I must do to get the worker working?
https, as it is a requirement for service worker to work?If you are not using HTTPS, the service worker will only be registered when accessing the application on localhost.which I do.