Build a Smart API Call Cache Layer with Configurable Expiry Time
Implement a caching wrapper around fetch (or any async function) that stores results keyed by the request URL/params, returns cached data on subsequent identical calls, and automatically invalidates the cache after a configurable TTL. Support force-refresh, cache-busting, and per-key expiry. This is the core of client-side request deduplication used in SWR, React Query, and custom API layers to minimize redundant network calls.