Questions tagged [angular-service-worker]

Questions related to the @angular/service-worker module, for automatically generating a service worker to power your Angular web apps.

Guidance for the @angular/service-worker module can be found at:

400 questions
94
votes
3 answers

Angular Service Worker - Failed to load resource: the server responded with a status of 504 (Gateway Timeout)

I am using the Angular-CLI 1.6.6 and @angular/service-worker 5.2.5 in our Angular 5.2.5 app. Everything works fine on the local lite-server, as well as on the production server, except for one error message popping in our production environment:…
41
votes
7 answers

Angular 5 and Service Worker: How to exclude a particular path from ngsw-config.json

I have ngsw-config.json (taken from the docs): { "index": "/index.html", "assetGroups": [{ "name": "app", "installMode": "prefetch", "resources": { "files": [ "/favicon.ico", …
ktretyak
  • 27,251
  • 11
  • 40
  • 63
34
votes
1 answer

Angular service worker is in SAFE_MODE

I have an Angular PWA. Its service worker was working flawlessly until I upgraded from Angular 5.0 to 7.2 After the upgrade, I see the following error in /ngsw/state Driver state: SAFE_MODE (Initialization failed due to error: Invariant violated…
shobhit vaish
  • 951
  • 8
  • 22
34
votes
2 answers

How to handle routing in Angular 5+ Service Workers?

In previous versions of the Angular service worker implementation, one of the config options was "routing". This can be seen in this unanswered SO question, was referenced in this Angular CLI issue, and the best remaining documentation seems to be…
19
votes
3 answers

Angular 7 Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script

I am getting the following error ERROR Error: Uncaught (in promise): TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. TypeError: Failed to register a ServiceWorker: A bad HTTP…
Blue Space
  • 627
  • 2
  • 7
  • 12
16
votes
3 answers

Angular 7 - Service Worker PWA + SSR not working on server

I am struggling to make my Server Side Rendering and Service Worker cooperate on server Side. Information regarding localhost -> Working This is working as expected. The service worker works and updates my app on every update. Moreover; a curl…
16
votes
2 answers

Angular ServiceWorkers + MIME type error

I'm trying to add service workers to our existing angular (5.2, CLI 1.7.1) application. I did everything I was suppose to: I created ngsw-config.json I run the the ng set apps.0.serviceWorker=true command so I have "serviceWorker": true, in…
Laker
  • 1,622
  • 4
  • 20
  • 32
15
votes
1 answer

serviceWorker removes Origin request header

I have an angular app and as soon as I add a serviceWorker following these steps: https://github.com/angular/angular-cli/blob/master/docs/documentation/build.md#service-worker https://angular.io/guide/service-worker-getting-started …my API requests…
14
votes
3 answers

Angular service worker and index.html caching

While there are similar posts, I can't find clear answer if index.html should be cached using Cache-Control header. Correct me if I am wrong, but right now I am returning Cache-Control: no-store for index.html to avoid hash mismatch errors which…
14
votes
1 answer

Angular Service Worker intermittently serving old version of application

I have an Angular application (version 7.2.2) using the Angular Service Worker (version 7.2.12). The service worker intermittently serves an old version of the application. On refresh the new version is shown, but if the user closes and reopens the…
abollinger
  • 143
  • 1
  • 5
14
votes
2 answers

Angular service worker not register in development mode

I would like to know if it' s possible to test pwa and register the serviceworker during the dev mode ( not production) As when i make the ng build --prod then launchhttp-server in the dist folder it works fine, but then when i do ng serve without…
dtjmsy
  • 2,664
  • 9
  • 42
  • 62
13
votes
8 answers

How to run service worker locally with Angular

I am following angular's best practice in order to make PWA. After making production build (ng build --prod --aot), I am also running the service worker from dist, on localhost: http-server -p 8080 -c-1 dist When I am trying to sync the worker…
13
votes
2 answers

Angular Push notification error in service worker, Unexpected token P in JSON at position 0

I am trying to use push notification in a pwa, but it is failing to receive the notification. On the client side I am receiving the following error Uncaught SyntaxError: Unexpected token P in JSON at position 0 at Driver.onPush…
12
votes
1 answer

Angular6 Service Worker and background sync

it seems that angular6 does not support background syncing with service worker. What are the steps required to do this without any library in an angular service? https://developers.google.com/web/updates/2015/12/background-sync How and where can I…
yonexbat
  • 2,902
  • 2
  • 32
  • 43
12
votes
2 answers

Caching of index.html in Angular Service worker

Everytime I make any change to the index.html with my Angular project, Service Worker never gets updated and always serves the old cached version on index.html. How do I fix this (Also, there is no caching at the server end as well as browser) Here…
Sampat
  • 1,301
  • 6
  • 20
  • 34
1
2 3
26 27