In a mobile sports fixtures-and-results app, how would you set different staleness rules for the fixture list, the league table and a match screen?
answer
- change rate versus cost of being wrong
- the window follows match state, not only time
- inside the window, send nothing
- a 304 saves the body, not the trip
- never show an old score as live
basics
~20 sGive each screen its own freshness window and ceiling from how fast its data changes and what a wrong value costs: fixtures hours, tables minutes, a live match seconds. Tighten windows by match state, and revalidate conditionally.
solid answer
~50 sI'd write one policy table in the data layer with three numbers per kind of data: a **freshness window** (show the copy, send nothing), a background-revalidation rule once it is older, and a **ceiling** past which the copy is shown only as `as of`. The inputs are how fast the data changes, the cost to the fan of a wrong value, and the cost of asking. So the fixture list is fresh for hours but tightens near that match's kick-off, the table is fresh for an hour on a quiet day and a couple of minutes while matches are on, and a live match snapshot for seconds, while a final score is effectively immutable. Revalidation sends the stored `ETag` in `If-None-Match`, so an unchanged list returns `304` with no body, though the round trip is still paid, which is why the window decides when not to ask at all.
code
http · 7 linesGET /leagues/l-1/fixtures?season=2026 HTTP/1.1
Host: api.example.com
If-None-Match: "fx-4471"
HTTP/1.1 304 Not Modified
ETag: "fx-4471"
Date: Sat, 10 Oct 2026 13:02:11 GMTgo deeper
Recall that different data goes stale at different speeds, and that each screen therefore needs its own window rather than one app-wide number.
Walk through the three numbers per screen and the inputs behind them, and explain what a conditional revalidation saves and what it still costs.
Make the windows depend on the data's state, such as kick-off approaching or a match in play, and define what the screen says once a copy passes its ceiling.
Treat staleness as a product contract: who sets each limit, how it is reviewed when traffic spikes, and how the cost of asking is weighed against the cost of being wrong.
## Why one lifetime does not fit every screen A **staleness policy** says, for each kind of cached data, how long a stored copy may be shown without asking the server (its **freshness window**), what happens once it is older, and how old it may get before the screen stops presenting it as current (its **ceiling**). In a sports app the three main screens change at very different speeds: - **Fixture list:** a season's schedule. It changes rarely, through a postponement, a kick-off moved for broadcast or a replay added. - **League table:** it changes only when results come in, so hardly at all on a quiet weekday and often while matches are being played. - **Match screen:** lineups an hour before kick-off, events during play, then a final score that does not change again. A single app-wide lifetime is either too long for the match screen or too short for the fixture list. Too long misleads fans; too short spends battery, data and server capacity refetching data that has not changed. ## Three inputs decide each window 1. **How fast the data changes, and when.** Change is not uniform: fixtures change near kick-off, tables change during match windows. 2. **The cost of being wrong.** A fan who arrives for a kick-off that was moved is badly served; a table two minutes behind costs little. 3. **The cost of asking.** Every revalidation wakes the radio, spends battery and data, and adds server load at exactly the moments fans arrive in bursts. Product owns the promise ("on a matchday the table is never more than a few minutes old"); engineering encodes it in one policy table in the data layer, so no screen invents its own rule and two screens showing the same table never disagree. ## A worked policy (this app's own assumptions) | Data | Fresh window | Ceiling, then shown only "as of" | Driven by | |---|---|---|---| | Fixture list | 6 h; 15 min within 3 h of that match's kick-off | 7 days | Late changes cluster near kick-off | | League table | 1 h with no match in progress; 2 min while one is | One matchday | Whether results can be arriving | | Match screen snapshot | 1 min before kick-off; 15 s while live | 1 min while live | Final score: fresh until a correction arrives | These numbers are assumptions for this app, not a standard. The point is the shape: the window depends on **the data's state**, not just on elapsed time. A finished match's result is effectively immutable; the same match during play is out of date within seconds. The live event stream that keeps an open match screen current is a separate real-time subject; this policy covers the cached snapshot the screen paints first and falls back to. ## When not to ask at all, and asking cheaply Inside the fresh window the app sends nothing: the stored copy is shown and the radio stays idle. Past it, the app shows the copy and revalidates in the background. **Conditional revalidation** makes an unchanged answer cheap. The app stores the response's entity tag (`ETag`) next to the entry and sends it back in `If-None-Match`. If nothing changed, the server answers `304 Not Modified`, which by definition carries no content, and the app resets the entry's fetched-at time. What that saves is the **body**, the whole fixture list, not the **round trip**: the request still crosses a possibly slow cellular link and waits for an answer. That is why the fresh window still matters: the cheapest request is the one never sent. ## What the screen shows past the ceiling - **Fixture list:** still shown offline with `as of Tuesday`, because an old schedule is mostly right; near match day the kick-off time carries a "may have changed" note. - **League table:** shown with its update time; once a whole matchday has passed unseen, the label becomes prominent. - **Match screen:** during play, a score more than a minute old loses its live marker and reads `last updated 15:42`. Presenting an old score as live is the one outright falsehood the policy exists to prevent. ## Common mistakes - Treating freshness as one number per screen instead of a function of the data's state. - Revalidating on every visit, so repeated navigation refetches unchanged data; offline-first guidance from a platform vendor names this as a drawback of fetching on navigation. - Assuming a `304` makes revalidation free on a slow network. - Letting each screen pick its own lifetime, so the home screen's table widget and the table screen show different standings.
- Why not simply refetch every screen each time the fan opens it?Because fans navigate in bursts, and most visits would refetch data that has not changed: radio wake-ups, battery and mobile data for nothing, plus server load concentrated around kick-off. A freshness window turns those visits into zero requests, and conditional revalidation makes the rest cheap when the answer is unchanged.
- On a slow cellular link, what does revalidating with a stored entity tag save, and what does it not?It saves the body: if the data is unchanged the server answers 304 Not Modified with no content, so a large fixture list is not downloaded again. It does not save the round trip; the request still waits on the network. On a slow link that latency is why the policy also decides when not to ask.
- Who should own these windows, and where should they live?Product owns the promise to the fan, such as how old a table may be on a matchday; engineering encodes it once in the data layer's policy table, keyed by kind of data and its state. Screens read through that policy, so the same data is never fresh on one screen and stale on another.
- A single cache lifetime suits every screen because all the data comes from one API.
- A 304 Not Modified response makes revalidation free on a slow network.
- Freshness depends only on how long ago data was fetched, never on the match's state.
- A finished match's result needs revalidating as often as a live one.
- A score a few minutes old may keep its live marker if the refetch failed.