Trust the cache, verify the network: a local-first catalogue
How the Nova widget app keeps its catalogue usable offline and refuses to replace good data with bad.
Status: Implemented and covered by automated tests; on-device validation is still to come.
Nova shows a catalogue of home-screen widgets that can be updated remotely. That raises two questions every connected app has to answer: what happens when the network is unavailable, and what happens when the network returns something wrong?
Read locally, always
The catalogue is read from a local database first. If the database is empty — for example on a first launch without a connection — the app falls back to a catalogue bundled with the app, so the screen is never empty because of the network.
Validate before replacing
- A remote catalogue is fetched and validated before it is used.
- If the request fails, the existing local catalogue is kept unchanged.
- If the payload is malformed or fails validation, it is rejected and the previous valid catalogue is kept.
- Only a valid payload replaces the cache, in a single transaction.
Why it matters
Separating “what the catalogue says” from “how a widget runs” means content can change without touching the widget engine — and a bad update can never break widgets that already work.