In a mobile puzzle game fetching remote configuration at launch, what does an offline first launch use, and when do fetched values take effect?
answer
- three layers, read in order
- the binary ships its own answers
- older than stale is the default
- fetch now, apply later
- never mid-level
basics
~20 sDefaults compiled into the build cover a first launch with no network; later launches use the last fetched values saved on disk. A new fetch is stored, then activated only at a safe point: the next launch or between levels.
solid answer
~40 sI'd read configuration through three layers. **Compiled defaults** ship in the binary and must give a safe, playable game on their own, because a first launch on a plane has nothing else. The **last fetched document** is saved on disk, outside any cache directory the OS may clear, and used offline for as long as it takes: it is newer than the defaults, so expiring it would make the app older, not fresher. A **fresh fetch** runs without blocking play and is only *staged*: the game activates the whole document at a safe point, the next launch or the level map between levels, so a move limit never changes mid-level and related keys switch together. Every read during a session comes from one snapshot.
code
pseudocode · 23 lineson launch:
active = load_activated_document_from_disk() # may be none on first launch
staged = load_staged_document_from_disk()
if staged is not none and staged.is_valid():
active = staged # activate at launch, before any level starts
save_activated_document(active)
clear_staged_document()
start_background_fetch()
on fetch_succeeded(document):
if document.is_valid():
save_staged_document(document) # stored, not applied
on level_map_shown:
if staged_document_waiting() and no_level_running():
active = take_staged_document() # removes it from the staged slot
save_activated_document(active)
read(key):
value = active.get(key) if active is not none else none
if value is none or not value.has_expected_type(key):
return compiled_default(key)
return valuego deeper
Recall the order of lookup: the activated fetched value first, otherwise the default compiled into the build, and the first launch with no network uses defaults only.
Explain fetch, stage and activate as three separate steps, why activation swaps a whole document, and why the stored document must live outside purgeable cache storage.
Show the judgement: choosing each key's activation point, refusing short expiry because defaults are older, and handling an invalid document without losing the last good one.
Frame defaults as code with a lifetime equal to the build's, and set the team rule for which keys may activate before the next launch and which never may.
## Three layers, one lookup **Remote configuration** is a document of named values (a move limit, a reward size, whether a level pack is offered) that a server publishes and an installed app reads, so behaviour can change without a store release. In an installed game it is never one source but three layers: 1. **The activated document** — the last fetched document that has been *activated*; every read looks here first. 2. **Compiled defaults** — a value for every key, built into this exact binary; a read falls back here when the key is missing from the activated document or has the wrong type. 3. **The staged document** — the newest fetch, saved on disk but never read until it is activated. A read never waits on the network and never fails. That rule is what makes a flag read safe to put anywhere. A common contract for client flag libraries says the same: every evaluation call carries a default value, and the caller gets that default whenever evaluation goes wrong, instead of an error. ## The first launch on a plane A casual game is often installed at the gate and first opened in airplane mode. There is no snapshot yet, so the **compiled defaults are the whole configuration**. That sets the bar for choosing them: - every default must produce a complete, playable game — the tutorial, the first level packs, the daily challenge's fallback; - a default for a risky or unfinished path is the *safe* side (off), because nobody can change it for that build later; - defaults are reviewed like code, because they are code: they ship in the binary and live as long as the build does. Blocking the first level until a fetch succeeds turns "no signal" into "no game", and it is exactly the case defaults exist for. How much a fetch may cost the launch path is a separate budget, owned by the question on cold start. ## Keep the last fetched document After the first successful fetch, the document is written to ordinary app storage. Two choices matter: - **Not a purgeable cache.** On one platform the system periodically clears the app's cache directories, and both platforms leave them out of device backups. A configuration kept there can vanish between launches, and the next offline launch silently drops back to defaults. - **No short expiry.** It is tempting to treat a twelve-hour-old document as stale and fall back to defaults. But the compiled default is older still — possibly two years old — and it does not contain last week's kill switch. Stale fetched values beat defaults; the snapshot is replaced only by a newer valid document. ## Fetch, stage, activate The fetch itself runs in the background, at launch or later. Its result is **staged**, not applied: | Moment of activation | Fits | What it costs | |---|---|---| | As soon as the fetch returns | nothing on screen depends on the value yet | a level, a shop price or an experiment can change under the player | | At the level map between levels | move limits, rewards, difficulty, pack lists | needs one clear "no level running" boundary in the game | | At the next launch | anything read once at start-up, such as whether a third-party SDK starts | a value waits until the next start, and some players keep the app suspended for days | Activation swaps the **whole document at once**. Keys that belong together — a new level pack and its difficulty table — must never be half old and half new. Inside a session, every read is served from the one active snapshot, which is what "values stable within a session" means in practice: the player who started a level with 30 moves finishes it with 30 moves, and the analytics for that level describe one configuration, not two. ## Edge cases interviewers push on - **A document that fails validation** is not activated at all; the last good snapshot stays. A single key read with an unexpected type still falls back to its compiled default at the read site, and the mismatch is reported, because it means the server published something an installed build cannot read. - **A sign-in** changes who the player is. Values targeted at the anonymous player may be wrong for the account, so the client fetches again for the new context and, like any fetch, activates the result at the next safe point. - **A kill switch** is the key you want soonest, and still not mid-frame: its safe point is "before the next use" of the guarded path, such as the next ad request, not the middle of a running call. ## What this question does not cover How often a particular remote-configuration product allows a fetch, and how much the fetch may add to launch time, are owned by other questions. What belongs here is the installed client's contract: defaults in the binary, the stored value on disk, and the moment a new value takes effect.
- Should a fetched document with one malformed key be rejected or applied?Validate before activating: a document that fails its schema is not activated, and the last good snapshot stays. If a single key still turns out unreadable at the read site, that read returns the compiled default rather than throwing, and the app reports the mismatch. Rejecting the whole document is safer when keys are related, because a half-applied pack list and difficulty table are worse than either old or new values.
- Why not simply expire a cached document after a day so players get fresh values?Expiry does not fetch anything; it only changes what an offline player falls back to. The fallback is the compiled default, which is older than any fetched document and knows nothing of recent kill switches or rebalanced levels. Freshness comes from fetching when a network exists, while the stored document stays in use until a newer valid one replaces it.
- What happens to configuration when the player signs in during a session?Values evaluated for the anonymous player may not match the account, for example targeting by purchases or region. The client fetches again for the new context and stages the result like any other fetch, activating it at the next safe point. A level already running keeps its snapshot; the change shows up at the level map or the next launch.
A football referee works from the printed rulebook until the league posts amendments; amendments announced during a match apply from the next match, never from the next play.
- The first level should wait until remote configuration has downloaded.
- A fetched value should apply the moment it arrives, even mid-level.
- Cached configuration should expire after a few hours and fall back to defaults.
- Keeping fetched configuration in memory is enough; the next launch can refetch.
- A missing or mistyped key should throw so the team notices it.