Skip to content

Unexpected cacheLife expire behaviour #78269

Open
@cduff

Description

@cduff

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dynamic RoutesRelated to dynamic routes.dynamicIORelated to dynamicIO.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions