Skip to content

feat(etag-test): restore ETag behavior for static pre-rendered page #80490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: canary
Choose a base branch
from

Conversation

maheshbhatiya73
Copy link

For Contributors

Adding or Updating Examples


What?

This PR adds an example under examples/etag-test that demonstrates how to restore ETag support for static pre-rendered pages in Next.js 15, and how the behavior compares to Next.js 14.

Why?

Starting with Next.js 15, React Server Components (RSC) are streamed by default, which disables automatic ETag headers on static responses.
Many developers upgrading from v14 expect 304 caching to work, but observe 200s instead.
This example helps validate and test that behavior explicitly.

How?

  • Added a minimal etag-test example with a static route (pages/index.tsx)
  • Verified that ETag headers are properly included
  • Tested curl with If-None-Match to confirm 304 Not Modified response
  • Example works with both Next.js 14 and 15 — great for comparing caching behavior

Fixes: #80452


Example path: examples/etag-test
Works in:

  • Next.js 14.1.4 → Static pages send ETag by default
  • Next.js 15.3.3 → Restores ETag by avoiding default RSC streaming behavior

To test:

pnpm install
pnpm build
pnpm start
curl -I http://localhost:3000/
curl -I -H 'If-None-Match: "<etag-value>"' http://localhost:3000/

@ijjk ijjk added the examples Issue was opened via the examples template. label Jun 13, 2025
@ijjk
Copy link
Member

ijjk commented Jun 13, 2025

Allow CI Workflow Run

  • approve CI run for commit: 36cf7e1

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

maheshbhatiya73 and others added 4 commits June 13, 2025 21:17
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@maheshbhatiya73 maheshbhatiya73 deleted the fix/etag-static-example branch June 13, 2025 16:02
@maheshbhatiya73 maheshbhatiya73 restored the fix/etag-static-example branch June 14, 2025 18:56
maheshbhatiya73 and others added 3 commits June 15, 2025 01:15
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
npx create-next-app --example etag-test etag-test-app
```bash
npx create-next-app --example hello-world hello-world-app
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a copy-paste error in the README.md installation instructions. The command references hello-world instead of etag-test:

npx create-next-app --example hello-world hello-world-app

This should be corrected to:

npx create-next-app --example etag-test etag-test-app

to ensure users install the correct example when following the documentation.

Suggested change
npx create-next-app --example hello-world hello-world-app
npx create-next-app --example etag-test etag-test-app

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Issue was opened via the examples template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to generate ETag for static pre-rendered pages in Next.js 15?
2 participants