In a mobile sports app, when a fixture's kick-off time changes, should the server push the new data or only a signal that marks it stale?
answer
- an id and a revision, not the data
- marking stale twice is harmless
- refetch when the screen is next seen
- the signal may never be processed
- visible screen first, the rest lazily
basics
~20 sUsually a signal: the fixture's id and revision. The app marks dependent entries stale, refetches visible ones now and others when next shown, and keeps expiry because a signal can be delayed or never processed.
solid answer
~50 sBy default I'd send an **invalidation signal** carrying the fixture id, a revision and a few tags, not the data. The app ignores it if its cached revision is already as new, otherwise marks the fixture list, both team pages and the match screen stale, revalidates whichever is on screen, and refetches the rest when they are next opened. Marking stale is idempotent, so duplicates are harmless and the revision check drops late, older signals. The data fetched later is the newest there is and can be personalised per user. Pushing the data pays only when it is small, self-contained and the same for everyone, and even then it is revision-checked. Since an app cannot count on running when a background signal arrives, the freshness window stays as the backstop. And when fans return in a burst, only the visible screen revalidates at once, with requests coalesced and spread.
code
json · 7 lines{
"type": "invalidate",
"entity": "fixture",
"id": "f-8812",
"revision": 18,
"tags": ["fixtures:2026-10-10", "team:t-12", "team:t-40", "match:f-8812"]
}go deeper
Recall that a server can tell an app that data changed, and that the app may still need to fetch the new version itself.
Explain why a signal carries an id and a revision, what idempotent handling means here, and why the freshness window remains.
Show the production judgment: design for signals that are late, duplicated or never processed, and keep a burst of returning fans from becoming a refetch storm.
Weigh push invalidation against polling and data push for each kind of data, including the server cost of fan-out and the client cost of waking up.
## The situation A broadcaster moves Saturday's kick-off from 15:00 to 17:30. Tens of thousands of fans have that fixture cached on their phones: in the fixture list, both teams' pages, the match screen and their home screen. Most of them are not using the app right now. The server knows the fixture changed; the design question is what it sends, and what each phone does with it. ## Two designs compared - **Data push:** the message carries the new fixture (kick-off 17:30, revision 18) and the app writes it into its cache. - **Invalidation signal:** the message says only what changed, fixture `f-8812` now at revision 18, and the app marks every entry that depends on it stale, refetching when the data is next needed. | | Invalidation signal | Data push | |---|---|---| | Payload | an id, a revision, a few tags | the changed data itself | | Personalised or access-controlled data | fetched with the user's own request | the sender must build it per user | | Signal lost | the freshness window still bounds staleness | the same | | Arrives late or out of order | revision check, then fetch the newest | revision check, or old data overwrites new | | Network needed to show the change | yes, when the screen is next seen | no | The default is the signal. Data a phone fetches when it next shows the screen is the newest there is, and one signal can invalidate many entries without the sender knowing what each phone has cached. Pushing the data pays in narrower cases: - the change is small and self-contained, such as a final score; - it is the same for every recipient, so no per-user payload has to be built; - seeing it without a network matters, because the fan may open the app underground. Even then the app compares revisions before writing it, and the freshness window stays in place. ## What the app does with a signal 1. Look up the entries tagged with the fixture: that day's fixture list, both team pages, the match screen. 2. Ignore the signal if the cached revision is already at or above the signal's. 3. Mark the rest stale, but keep showing them until a refetch replaces them. 4. If one of them is on screen, revalidate now; otherwise refetch when that screen is next shown. Marking stale is **idempotent**: a signal delivered twice has the same effect as once, and an older signal arriving late is dropped by its revision. ## Design for the signal that never arrives An app cannot count on running when a background signal arrives. It may have been killed, the system may defer or limit background work, the user may have switched notifications off, and the phone may be offline. So: - **Expiry stays.** Push invalidation shortens staleness when it works; the freshness window bounds it when it does not. - **Reconcile on return.** After a long gap in the background, the app treats its entries as possibly stale and revalidates the visible screen. - **A quiet channel proves nothing.** No signal never means nothing changed. Delivering the signal, through the push pipeline or the socket that carries live match events, belongs to the real-time and server-side designs; this policy covers only what the signal does to the cache. ## The foreground refetch storm Signals and kick-off bring fans back in bursts. A phone returning after three hours may hold a dozen stale screens: the back stack, the home screen, a widget. If each one refetches the moment the app opens, the phone fires a burst on a congested network, and a hundred thousand phones doing it together create a server spike at the worst minute. Limit it: - **Revalidate what is visible first**; refetch other screens lazily, when they are opened. - **Coalesce requests**: one in-flight request per key, shared by every screen that asks for it. - **Revalidate conditionally**, so an unchanged entry costs headers, not a body. - **Spread background refetches** with a random delay instead of firing them all at the same instant. - **Honour back-pressure**: on `429 Too Many Requests` or `503 Service Unavailable` with `Retry-After`, wait as told and keep serving the stale copy meanwhile.
- The signal arrives twice, or an older signal arrives after a newer one. What breaks?Nothing, if the handler is built for it. Marking an entry stale twice is the same as once, and each signal carries a revision, so one at or below the cached revision is ignored. A pushed-data design is where order bites: writing an older payload over a newer one silently restores the wrong kick-off time.
- A kick-off change reaches 200,000 followers at once. How do you stop the app turning it into a load spike?Do not refetch on receipt for screens nobody is looking at; mark them stale and fetch when opened. On open, revalidate only the visible screen, coalesce duplicate requests per key, spread non-urgent refetches with a random delay, use conditional requests, and honour 429 or 503 with Retry-After while showing the stale copy.
- When is pushing the data itself the better choice?When the change is small, self-contained and the same for every recipient, and seeing it without a network matters, for example a final score for a followed team. Even then the payload carries a revision the app checks before writing, and the freshness window remains in case the message is never processed.
- A background push guarantees the app wakes and refreshes before the fan opens it.
- Once push invalidation exists, cached entries no longer need any expiry.
- Pushed data can be written over the cache without comparing revisions.
- Refetching every affected entry the instant a signal arrives costs nothing extra.
- Refetching every stale screen on foreground is harmless because each request is small.