The proxy fetches from an API endpoint that has a 1000ms delay
Uses SWR (Stale-While-Revalidate) caching strategy with separate revalidate and expiry times
Cache HIT: Fresh cached data served instantly (~0-5ms)
Cache STALE: Cached data served instantly, background refresh scheduled via Next's after() (~0-5ms)
Cache MISS: No cached data available, full API delay incurred (~1000ms)
Data is fresh for 5 seconds (revalidate time)
After 5 seconds, data becomes stale but is served instantly while refreshing in background
After 30 seconds, cache expires completely and requires a fresh fetch
The random value helps verify when the cache is actually being used
Expire Cache calls expireTag('demo-api'); the next load is a MISS regardless of age. The same call works from a Route Handler (POST /api/expire) for webhook-driven invalidation
Cache status provided via response headers: X-Cache-Status, X-Cache-Age, X-Cache-Expires-In