1

We have an angular 5 app that is used on mobile in google chrome browser. The users are always in the app, so they are not closing browser or calling the app new. if we update now the dist because we build a new version, how can we be sure that the users are getting the new build? our workaround was an window.location.reload(); but its not really smooth.

is there a other solution?

Florian Widtmann
  • 524
  • 4
  • 15
  • Well we have focused the same problem and solved it by listen to a SignalR Service. Could also be a socket.io Server/Client implementation. Then if we release a new version we can send a refreshEvent with or without force option. That triggeres in the end the `window.location.reload(boolean)`. – JohnnyDevNull Oct 05 '18 at 08:45
  • Service worker already does everything you want. Just use it – smnbbrv Oct 05 '18 at 09:17
  • @smnbbrv can you explain it to me? because we are already using service worker (PWA) – Florian Widtmann Oct 06 '18 at 07:10
  • 1
    https://angular.io/guide/service-worker-communications - you get an update and refresh the page. There is no other way you can do the update other than refresh, currently. If you want to make it that smooth that nobody even understands that will consume lots of your time and in the end will never be stable. Browser refresh is the best here – smnbbrv Oct 06 '18 at 08:04
  • @smnbbrv thanks i got it running local and its working like a charm - but on our server (https) its not working (not getting update) - do you have any idea? – Florian Widtmann Oct 06 '18 at 09:37
  • found the solution in https://stackoverflow.com/questions/50968902/angular-service-worker-swupdate-available-not-triggered – Florian Widtmann Oct 07 '18 at 08:30

1 Answers1

1

I faced same issue today. For angular easy solution is to use

ng build --output-hashing all

The command will hash all your files and add hash to their names. If file is modified, hash is changed and so is file name, forcing the browser to download the new version of that file.

Max Tuzenko
  • 1,051
  • 6
  • 18