Cache That Tells the Truth

Decide what you would build from the brief alone. Everything below it is available, but the exercise stops working if you open it first.

The brief you were given

Navigating back to a list re-fetches everything and shows a spinner over content the user was just looking at. Implement stale-while-revalidate so the list appears instantly and updates when fresh data lands.

The trap — the wrong fix that looks right

Clearing the whole cache on logout to solve the shared-machine problem, which does fix the case anyone tests. The account identity is still not in the key, so the failure remains wherever a logout does not happen: a session that expires and is renewed as a different user, an account-switcher that swaps context without a full logout, two tabs signed into different accounts against the same origin, or a token refresh that returns a different subject. Clearing on logout handles the one transition someone thought of; putting the identity in the key makes the collision impossible.