Skip to content

Calling notFound() on a page that is force-static gets cached #81290

@yoohahn

Description

@yoohahn

Link to the code that reproduces this issue

https://github.com/yoohahn/nextjs-notFound-cached

To Reproduce

  1. yarn preview
  2. Go to http://localhost:3000/en/404

Check the Cache Control header.

Current vs. Expected behavior

The route that matches the condition for our notFound() to be call is cached. It is expected that a 404 is not cached and gets the Cache Control value Cache-Control private, no-cache, no-store, max-age=0, must-revalidate, as done when going to http://localhost:3000/en/nope

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202412060638~1748542656~22.04~663e4dc SMP PREEMPT_DYNAMIC Thu M
  Available memory (MB): 31765
  Available CPU cores: 20
Binaries:
  Node: 24.0.1
  npm: 11.3.0
  Yarn: 4.6.0
  pnpm: N/A
Relevant Packages:
  next: 15.3.4
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Error Handling, Headers

Which stage(s) are affected? (Select all that apply)

Other (Deployed), Vercel (Deployed), next start (local)

Additional context

I found this issue that looks similar;
#75023
and should have been fixed in github.com//pull/75009

But that pr is in 15.3.4 that I am running. I have also tested next@canary but the same there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error HandlingRelated to handling errors (e.g., error.tsx, global-error.tsx).HeadersRelated to the async headers() function.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions