Skip to content

feat(servers): cache featured servers on disk and refresh them in the background - #68

Merged
notchyves merged 1 commit into
theselauraproject:mainfrom
NaySurGithub:feat/featured-cache
Nov 6, 2026
Merged

notchyves merged 1 commit into
theselauraproject:mainfrom
NaySurGithub:feat/featured-cache

Conversation

@NaySurGithub

Copy link
Copy Markdown
Contributor

Problem

The featured servers tab starts empty on every launch. Perlin::RefreshFeatured only kept the list in memory, for 10 minutes. Before showing anything, it had to:

  1. sign in to Xbox Live (SignInSaved);
  2. call the featured API;
  3. download every logo, one after the other, with an 8 s timeout each.

tabFeatured was only filled at the very end, so one slow logo held back the whole list. Logos were never stored on disk and were downloaded again each launch. A failed call (network, expired token) left the tab empty.

Change

Featured servers now work as stale-while-revalidate:

  • Disk cache in <data dir>/featured/:
    • servers.json: name, description, host, port, logo URL, ranked, rank;
    • logos/<FNV-1a of the URL>.png. A server that changes its logo gets a new URL, so a cached file never goes stale.
  • Instant display: the first RefreshFeatured of a session loads the cache and its logos from disk, fills tabFeatured and starts the pings, before any network work.
  • Background refresh on every launch and every visit to the tab. The 10-minute throttle is gone, since the display no longer waits on the network; featuredBusy still prevents overlapping requests.
    • the network list replaces the shown one as soon as the API answers, and is written to the cache;
    • logos that are not on disk then download in parallel, are written to logos/, and update the rows' icons;
    • a failed call keeps the cached list instead of clearing it.

Testing

macOS arm64 Release build, signed-in Microsoft account:

  • First launch (empty cache): servers.json is written with 7 servers (Mineville Zeqa, The Hive, CubeCraft, Lifeboat, MegaSMP, Enchanted, Galaxite) and logos/ with 7 files.
  • Next launch: the log shows 7 servers (7 logos) from the cache at line 7, before Xbox sign-in. The network refresh then logs 7 featured servers and replaces the list.
  • Not tested yet: switching accounts, and a launch with no network at all (the cached list should stay).

… background

The featured tab was empty on every launch until Xbox sign-in, the
featured API call and every logo download had finished, one logo at a
time with an 8 s timeout each. A failed call left it empty.

The list and its logos are now kept in <data>/featured (servers.json and
logos named by url hash) and shown at once. Every launch and every visit
to the tab refreshes them in the background; the network list replaces
the shown one as soon as it arrives, logos follow in parallel, and a
failed call keeps the cached list.
@notchyves
notchyves merged commit cf848f5 into theselauraproject:main Nov 6, 2026
11 checks passed
@NaySurGithub
NaySurGithub deleted the feat/featured-cache branch November 6, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants