DEV Community

Discussion on: Can you please refresh (Or how we version our Single-Page Application)

Collapse
layzee profile image
Lars Gyrup Brink Nielsen

I liked your considerations and approach. But isn't this is something that is already solved by a service worker? Events for update notifications and triggering of updates.

Collapse
originalexe profile image
Ante Sepic Author • Edited

Hey Lars, thanks for the feedback.

As far as I am aware, a service worker checks for the new version availability on page load, but we needed the checks for people who were idle, or who were just browsing the app without refreshing.

Additionally, even if it would technically do what we needed it to, we were not making use of the service worker in that particular spa, so adding an additional script just for the update detection mechanism did not seem worth it.

Lastly, we also support IE11 on our app, so that was taken into consideration as well.

Collapse
layzee profile image
Lars Gyrup Brink Nielsen • Edited

I see. What about this issue, how are you going to handle that?

Without service workers, users can load one tab to your site, then later open another. This can result in two versions of your site running at the same time. Sometimes this is ok, but if you're dealing with storage you can easily end up with two tabs having very different opinions on how their shared storage should be managed. This can result in errors, or worse, data loss.
From developers.google.com/web/fundamen...

Registered service workers have an update method to check for updates manually.

Thread Thread
originalexe profile image
Ante Sepic Author • Edited

Actually, in this case, we actually prefer to notify the user about the update in every tab.
It would be bad to not show the notification in every tab (we ideally don't want users to run the old version in some of them), but we also can't refresh all tabs at once (some of them might have data that the user does not want to lose).

I hope that makes sense, but let me know if I am missing your point.