Open
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/next-cache-life-expire-issue-c6wdvt
To Reproduce
- Execute commands:
npm run build
npm start
- Browse to root page. Take note of displayed time.
- Wait 5 mins.
- Refresh page once. Note that old time is displayed.
Current vs. Expected behavior
This project is using the new canary dynamicIO
, use cache
and cacheLife
functionality.
The documentation for cacheLife
expire
says:
Maximum duration for which a value can remain stale before switching to dynamic fetching
The following is specified in the sample project:
cacheLife({ stale: 60, revalidate: 3 * 60, expire: 5 * 60 });
Therefore, when refreshing the page after waiting 5 minutes, I expect it to switch to dynamic fetching and return the current time. This is the functionality I want and expect. Instead, the old stale/expired value is being returned.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4242
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.3.1-canary.11 // Latest available version is detected (15.3.1-canary.11).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
dynamicIO, Dynamic Routes, Use Cache
Which stage(s) are affected? (Select all that apply)
next start (local)
Additional context
BTW, not being able to specify an expire time less than 5 minutes is really annoying and makes issues like this hard to debug!