Vignesh Waran
Vignesh Waran

Reputation: 1

When should I re-register the angular service worker in my application

  1. what is the need to change/update the new service worker in the client since there is no change in the ngsw-worker.js

  2. whenever ngsw.json is updated, on the first reload, new content changes inside my application are not being updated in UI due to the fact that ngsw.json is loading late. Is there a way to bring it to the top

I am using angular service worker.

Inside my app component I also have injected SWUpdates and i am checking for updates.

when i change my ngsw-config.json or update the contents of code(.ts, .css, .svg ), the angular build is generating two files inside my dist, one is ngsw.json and ngsw-worker.js.

ngsw.json has the hashtable of each of the file in the code.

whether i change the code content or if I change the ngsw-config.json along with version number, only the ngsw.json inside the dist is getting updated and the ngsw-worker.js remains the same.

I have verified it several times and this is how its working. With this scenario, I have following two doubts

**

  1. what is the need to change/update the new service worker in the client since there is no change in the ngsw-worker.js

  2. whenever ngsw.json is updated, on the first reload, new content changes inside my application are not being updated in UI due to the fact that ngsw.json is loading late. Is there a way to bring it to the top **

second question is due to the below scenario,

in my single page application, say i have two svg files, svg1 and svg2. sv1 is very early on the page and svg2 is loading late because its somewhere at the bottom.


say svg1 is loading even before ngsw.json is loaded in network tab, code updates (say new path added or color updated) is not reflected in UI

whereas, svg2's code updates are reflected in UI because , because service worker already knows that its hash has been changed provided the fact that the ngsw.json is downloaded

Upvotes: 0

Views: 51

Answers (0)

Related Questions