Force users to refresh to use new version of webapp?

So I fixed a bug yesterday.
Today Sentry is saying it regressed. I see one event this morning.

However, I highly doubt it really regressed and then I realized that it could be that the user still had a tab open and doesn’t run the latest client side code (the bug was in client side).

Is there a way to force the user to refresh and thus load the newest version on deployment?
Ideally this isn’t the default behaviour though. There are situations where we don’t want users to refresh.
And most ideally we also limit this to certain routes, so if people are on our CMS routes then they should refresh. but on other routes they shouldn’t (like the home page)

On some projects I have a Server Action that just pulls a version number from the server. On success - If that version number is greater than the client-side one (I actually set via server-side binding using the same version SC when the page is rendered, although a variable would work just as well), I get the Browser component to do a refresh.

If you have a Service Worker with caching strategies, you may need to tinker with it, but it generally works well.

You could apply a condition on the refresh, using the pathname from Browser or only add the SC that pulls the version and calls the refresh to pages where you want it to happen.

1 Like

We have used a similar setup in the past.
Additionally, we also add version suffix to common JS/CSS includes.

3 Likes

Great minds…
A definite worthwhile step

@bpj
When do you run the server action though? Autorun? Because then a refresh anyway needs to happen.
Or you loop that server action client side, and just run it every minute or something?

@sid
I think I’m missing the point of this, you add it to your own JS/CSS files I assume? So you can keep track of changes there?

If you are using NodeJS why not send a message (broadcast) to the users / show alert that they need to refresh the dashboard?

1 Like

Yes. And also in one app we use CDN, so all the Wappler files are also served from a different URL. And in those include URLs, I have added an ENV variable as version. So anytime there is a Wappler update, I just change the ENV and CDN serves the latest file.

But for other use cases, yes, versioning is on my own files.

1 Like