25
Backend
04
Security
08
iOS
07
Infra

Persist Apollo's normalized cache in SQLite and clear it on sign-out

ADR-0015 ACCEPTED · 2025-07-27
Persist Apollo's normalized cache in SQLite and clear it on sign-out

Decision

Back the app's Apollo client with SQLiteNormalizedCache, so the data it last fetched survives a restart and can be shown offline. Clear the cache on sign-out and when the server rejects the session, because the cache outlives the session and would otherwise show one account's data to the next.

Why

People use the app while travelling, often with no signal. Apollo iOS offers the normalized cache in memory or in SQLite. After the OS kills the app while the device is offline, only the SQLite store leaves anything to show.

Rejected alternatives

  • Memory only. It is faster and simpler, but a restart wipes it and an offline traveller has nothing to look at.
  • Memory in front of SQLite. It buys a speed-up nobody has shown we need, and the two caches must agree.

Consequences

Reads are slightly slower than from memory. The cache sits on disk across sessions, so keeping accounts apart depends on every sign-out path clearing it.