Sync Patterns Without Heavy Libs
Use simple sync patterns: stale-while-revalidate, background refresh, refetch on focus/retry, and time-based revalidation.
Why sync patterns?
Goal: Keep data fresh without heavy libs.
- SWR: show cache, then refresh
- Background refetch
- Focus refetch & retry
- TTL revalidation
Core principles
- Keep a tiny cache map: key → { data, ts }
- Render cache if present; fetch in background
- On success, swap data; on fail, keep old and show hint
All lessons in this course
- Distinguishing Server Data and Local UI State
- Normalization & Optimistic Updates (Concepts)
- Sync Patterns Without Heavy Libs