-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
context.res.setHeader not setting Cache-Control #62294
Comments
This comment has been minimized.
This comment has been minimized.
Exact same issue here. This is costing us a lot of money when Google crawls our website especially... Did you find some workaround for it? |
Hi @victorcarvalhosp, no I didn't. The only other options are SSG, implement your own caching of data eg with redis, or migrate to app router. These aren't satisfactory workarounds since they are not necessarily appropriate for a page you want to cache depending on requirements |
Migrating to app router might not help much. There are a lot of little things that can make a page dynamic and it won't cache at all. For instance, in v13 with pages router I could have a static page that accepted query strings (provided that those query strings are used only in client side), now I can't and the page must be dynamic, which in pages router with v13 I solved setting a cache header because I have Clouflare in front of Vercel. But with v14 it is impossible to set that header so dynamic pages can't be cached in Vercel and anywhere else! |
I had the exact same problem when I started migrating to the app router, so we decided not to proceed with that for now, as it would be a lot of work and we couldn't even be sure if it would cost less. |
Link to the code that reproduces this issue
https://github.com/eloisetaylor5693/nextjs-set-cache-control
To Reproduce
results in the response header
Cache-Control: no-store, must-revalidate
Current vs. Expected behavior
When testing in the browser, the response header doesn't include the cache control I set
Current:
Cache-Control: no-store, must-revalidate
Expected:
Cache-Control: public, s-maxage=300, stale-while-revalidate=600
Provide environment information
Which area(s) are affected? (Select all that apply)
Data fetching (gS(S)P, getInitialProps)
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: