Search code examples
angularprogressive-web-appsservice-workerangular-pwa

Why did angular service worker isn't registered


I have added angular2 pwa to my project but when I try to build and start it with prod build for some reason service worker isn't working. Configuration seems to be proper, I've added and registered it in the main module with: ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }). But when I start app service worker isn't running. If someone had similar issues???


Solution

  • Just try to add registration strategy to your configuration:

    ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerImmediately' })