Skip to content

SPA content refresh with constant updating

I know that recommended approach to updating SPA versions is to use service workers and alert user that he should refresh page. But what options do we have when there’s lots of pages and new things constantly getting added? I believe this would annoy a lot of users especially when those updates aren’t even related to the page they are using right now.

I was thinking about whenever new version exists refresh page when user goes to other page like clicking menu item. But it’s far from perfect. Do I have other options?


You can achieve this task – “Show the alert to refresh the page when there is a new UI version available for the page being viewed by the user”.

For that, you need to store version and updated UI modules for that version at the backend. e.g. lets say Report-1, Report-5 were changed in a new version 1.2.3.

Now, UI can send current UI version with each AJAX HTTP call (maybe in custom headers) and if the backend finds that UI is stale, it can respond with the new version and the list of changed UI modules: e.g. new version: 1.2.3 and changed UI modules: Report-1, Report-5.

Now UI can decide whether to show an alert or not by checking if the user is currently looking at one of the changed modules (which are Report-1 & Report-5 in this example).

So, for this example:

if the user is looking at Report-1, show the alert.

if the user is looking at Report-6, don’t show the alert.