-
Notifications
You must be signed in to change notification settings - Fork 27k
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
fix: allow next.config.js
overwrite cache-control
header
#39707
Conversation
I would be interested in the merge of this PR too 👍 |
Hi, |
df8579c
to
47e5ebe
Compare
e078ebe
to
6b863fe
Compare
@ijjk this feature is important for everyone who uses self-hosted + Cloudflare. |
Any movement on this? |
Maintainers, please, could you review this change? |
@timneutkens @stefanobrambilla @ijjk @shuding @huozhi @feedthejim |
This is a relatively small, opt-in change with huge usability benefits; both the issue and the solution are straightforward, can this please be prioritized? |
This is still an issue. I would like to cache ISR pages locally, but not on the CDN. There seems to be no way to overwrite the |
Adding one more voice to the crowd of people affected by that issue - please review it and either provide a clear explanation on why it's undesirable - or get it merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, went ahead and landed this against latest changes with added tests in #69802 thanks for looking into this!
Update (2022-12-31): My Solution
Fixes #21827, fixes #22319 #28557
https://nextjs.org/docs/api-reference/next.config.js/headers#cache-control
In the documentation it is described that
Cache-Control
cannot be overridden and will affect static resources, but in fact static resources will set their ownCache-Control
, so it does not seem to affect them.next.js/packages/next/server/next-server.ts
Lines 428 to 451 in 9c41634
I use
getHeader('Cache-Control')
to check if the user has set their cache, which by default is the same behavior as before.By the way
hasHeader
isundefined
in some cases, I don't know why. (#34929 #37338)