If I make changes to my angular app the chunk names will change on build and the old version will be remove from the dist folder. Once deployed if a user is currently on the site and then navigated to another part of the site I get a loading chunk failed error as the old file is no longer there.
My app is built using angular cli so it's packaged using webpack.
Is there anyway this can be overcome.
Disable the hashing of chunks
For more information see the official build documentation
I know I'm a little late to the game on this questions, but I would recommend changing your deployment approach.
Check out https://immutablewebapps.org/. The basic philosophy is to isolate you build time assets from your runtime variables. This provides a bunch of benefits, but the biggest are:
This also should not interfere with the ** PreloadAllModules** suggestion offered by @dottodot below.
I keep my old chunks in place for a couple days after an update for just this purpose. My app also consists of mini-SPAs, so as they move around, they're likely to pick up the new version during a page load.
I had the same problem and found a pretty neat solution that is not mentioned in the other answers.
You use global error handling and force app to reload if chunks failed.
It is a simple solution and here (Angular Lazy Routes & loading chunk failed) is the article I got it from.
Clear Browser cache. Worked for me
You can send some event from server side to reload the application. Also there is option to pre fetch the lazy modules in background so as to prefetch them as soon as possible instead of waiting for the request of that modules.