Skip to content

Commit 3dafab9

Browse files
authored
[Cache Components] Allow stale longer than expire in cacheLife (#85115)
We previously encoded an invariant with cacheLife that required stale to be greater than expire. This doesn't really make sense because these describe completely different lifetimes. Stale starts from when the client reads the response but expire starts from when the cache entry is created. This removes the the requirement that expire be greater than stale
1 parent 149f18e commit 3dafab9

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

packages/next/src/server/use-cache/cache-life.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ function validateCacheLife(profile: CacheLife) {
7272
)
7373
}
7474
}
75-
76-
if (profile.stale !== undefined && profile.expire !== undefined) {
77-
if (profile.stale > profile.expire) {
78-
throw new Error(
79-
'If providing both the stale and expire options, ' +
80-
'the expire option must be greater than the stale option. ' +
81-
'The expire option indicates how many seconds from the start ' +
82-
'until it can no longer be used.'
83-
)
84-
}
85-
}
8675
}
8776

8877
export function cacheLife(profile: CacheLifeProfiles | CacheLife): void {

0 commit comments

Comments
 (0)