SWR vs maxStaleAge
How do swr and maxStaleAge in a defineCachedEventHandler play together? The docs say:
swr: boolean
Enable stale-while-revalidate behavior to serve a stale cached response while asynchronously revalidating it. Defaults to true.
staleMaxAge: number
Maximum age that a stale cache is valid, in seconds. If set to -1 a stale value will still be sent to the client while the cache updates in the background. Defaults to 0 (disabled).
So swr
defaults to true
, and a stale cached response should be served. However, staleMaxAge
defaults to 0
, which means a stale cache is always invalid and will not be served to the client? This doesn't make any sense, does anyone have insight?0 Replies