2

I have an Angular 10 .NET application hosted at https://myapp-fnl/#

The application has cache-busting implemented via an ngsw-worker that I discovered does not work properly. The service-worker is registered, and I can see my cached files, but when attempting to download updated files when a new version is released, it fails.

The cache busting request is as following : Cache-Busting Request Headers

As you can see the request URL is https://myapp-fnl/ngsw.json?ngsw-cache-bust=0.6.....

However, afterwards the ngsw-worker attempts to fetch the files from what I believe is the wrong URL https://0-es2015.e6c.... it produces the following error:

Driver state: EXISTING_CLIENTS_ONLY (Degraded due to failed initialization: Response not Ok (fetchAndCacheOnce): request for https://0-es2015.e6c696f9930a07feea1d.js/ returned response 504 Gateway Timeout

I believe the proper url request would be something along the lines of https://myapp-fnl/0-es2016.e6c.... Invalid URL Request

Does anyone happen to know the best way to modify the URL that ngsw uses? My application URL also varies per enviornement. Ex (myapp-fnl, myapp-qc, myapp-prod)

Thank you

cicero866
  • 75
  • 5
  • Did you set the `basehref` in Angular? – Zze Apr 26 '22 at 20:46
  • I've went over the basehref documentation https://angular.io/guide/deployment#the-base-tag . We are setting it. However baserefh is not used to set the www.myapp-fnl.com/# portion from from my understanding. Rather it's used when you're application is in a subfolder on the server. In my case it's not, so we're passing --base-href .\ as an argument. – cicero866 Apr 26 '22 at 23:20
  • 1
    Did you ever find a solution to this? I have a but the ngsw-worker.js keeps requesting the ngsw.json from the root. I expect it to be foo.com/v1/ngsw.json but it's just foo.com/ngsw.json (which doesn't exist) – Shawn Feb 01 '23 at 20:06
  • @Shawn this is also my exact issue! This is preventing loads/refreshes in production requiring a second refresh in order to load correctly. I too am keenly interested in more information here and will continue to do research. – ccampanale Jun 16 '23 at 19:01

0 Answers0