Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Unexpected `cacheLife` `expire` behaviour | GoodFirstPicks

Unexpected `cacheLife` `expire` behaviour

vercel/next.js 2 comments 11d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

Cache expiration behavior does not match documented expectations.

AI Summary

The issue involves unexpected behavior in the `cacheLife` `expire` functionality where stale values are returned instead of dynamically fetching new data after the specified expiration time. The problem is reproducible and affects dynamic routes and cache components. The fix requires understanding cache mechanisms and dynamic fetching in Next.js.

Issue Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/next-cache-life-expire-issue-c6wdvt

To Reproduce

  1. Execute commands:
npm run build
npm start
  1. Browse to root page. Take note of displayed time.
  2. Wait 5 mins.
  3. 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!

GitHub Labels

Cache ComponentsDynamic Routes

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • cache behavior
  • dynamic fetching
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno