getodk / getodk/central

Don't send requests for version.txt from every tab

Open
#1,284 0 comments 0 reactions 0 assignees View on GitHub
frontend refactor
Dominant language
JavaScript
Stars
226
Forks
235
Avg merge
2d 22h
Merged PRs (30d)
19

Description

Frontend requests /version.txt every minute in order to check whether the server has been rebuilt. It shows a message if version.txt has changed. This is implemented using the `checkVersion()` method of the `App` component.

Requesting /version.txt every minute is already a lot of requests. That number is compounded by the fact that every tab is sending that request every minute. Instead, I think it'd be better if only one tab sent a request each minute. If one tab has sent a request for version.txt in the last minute, then other tabs don't need to.

One sequence to consider

- Open Frontend in one tab.
- Upgrade the server.
- Open Frontend in another tab before the first tab next requests /version.txt.
- Once the first tab has received version.txt, it should show an alert and inform the second tab about the latest content of version.txt. But the second tab shouldn't show an alert because it is already on that version. In this sequence today, the second tab wouldn't show an alert.

One way we could implement this is using local storage, similar to how we implement simultaneous logout across tabs. I also noticed that [`BroadcastChannel`](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) is at last supported in Safari, so that's something we may be able to use as well.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.