Performance: Data cache behavior
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how data is reused or refetched in Next.js apps.
import useSWR from 'swr'; const fetcher = url => fetch(url).then(res => res.json()); const { data } = useSWR('/api/data', fetcher);
useEffect(() => { fetch('/api/data').then(res => res.json()).then(setData); }, []);| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No cache, fetch on every navigation | Minimal | 0 | High due to delayed paint | [X] Bad |
| Client-side cache with SWR or React Query | Minimal | 0 | Low, immediate paint with cached data | [OK] Good |