Skip to content

Cache headers on 404 pages with getStaticPropsΒ #22579

@gdorsi

Description

@gdorsi

What version of Next.js are you using?

10.0.6

What version of Node.js are you using?

14.15.1

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Other platform

Describe the Bug

The 404 error page responds with the cache headers cache-control: s-maxage=31536000, stale-while-revalidate when the getStaticProps function is exported.

This could be a problem when the resource is temporary unavailable.

Expected Behavior

The cache headers for the 404 responses should be cache-control: public, max-age=0, must-revalidate like when the getStaticProps function is not exported.

To Reproduce

  1. npx create-next-app
  2. Add a 404.js page with getStaticProps
  3. npm run build && npm start
  4. Request a non-existent route, like http://localhost:3000/_next/static/give-me-a-404-response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions