ETags in Next.js App Router #74915
Replies: 2 comments 10 replies
-
I have found some more information about this issue. It appears to only affect dynamic routes. For dynamic routes, no ETag is generated on the HTML document. When I add export const dynamic = 'force-static'; to my dynamic route, an ETag is generated on the HTML document. However, this setting has a major drawback: it causes the cookies, headers(), and useSearchParams() functions to return empty values (source: Next.js Documentation about dynamic). This is the piece of code in Next.js where it intentionally does not generate an ETag for dynamic routes. https://github.com/vercel/next.js/blob/v15.1.6/packages/next/src/server/web-server.ts#L296 So, the questions that remain are:
|
Beta Was this translation helpful? Give feedback.
-
+1 pretty depressing to not mention in documentation that e-tag is not generated for app router |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've encountered an issue with the Next.js app router where ETags are not automatically applied to the HTML document. They are applied to all other files, but not to the HTML document. I used create-next-app and set generateEtags: true in the next.config.js file (even though this is the default setting). However, the HTML document still doesn't have an ETag.
Why is this happening, and how can I resolve it? I need ETags for the HTML document for caching purposes.
Beta Was this translation helpful? Give feedback.
All reactions