next.js
f63290fe - [Segment Cache]: fix infinite prefetching when staleTime is 0 (#82388)

Commit
138 days ago
[Segment Cache]: fix infinite prefetching when staleTime is 0 (#82388) This PR fixes an infinite loop bug that occurred when using `cacheLife({ stale: 0 })` with `clientSegmentCache`. When the server returned a stale time of 0 seconds, cache entries would have `staleAt = Date.now()`, making them immediately stale. The cache would evict these entries on the same tick they were created, triggering continuous refetch requests. The fix updates the minimum stale time to be 30s, in the event that the server sends a low value. The rationale being that a value lower than 30s here would render prefetching ineffective. This prevents the immediate eviction while still respecting the server's intent for very short-lived cache entries. Closes NAR-269
Author
Parents
Loading