Caching Strategy
Strategi
| Strategy | Deskripsi | Cocok untuk |
|---|---|---|
| Cache-First | Tampilkan cache dulu, update di background | Master data, profile |
| Network-First | Request API dulu, fallback ke cache | Feed, transactions |
| Stale-While-Revalidate | Tampilkan cache + request API bersamaan | Dashboard, list data |
| Network-Only | Selalu dari API, tidak cache | OTP, payment |
| Cache-Only | Hanya dari cache | Offline mode, draft |
Cache Expiry
| Data Type | TTL | Contoh |
|---|---|---|
| Static/Config | 24 jam | App config, feature flags |
| User Profile | 1 jam | User data, preferences |
| List Data | 5–15 menit | Product list, feed |
| Real-time | 0 (no cache) | Chat, notifications |
tip
Untuk React Native, gunakan TanStack Query yang sudah memiliki built-in caching strategy (staleTime, gcTime, refetchOnFocus).