You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for Next.js and it's 9.3 version, it's amazing.
Describe the bug
I'm trying to set reasonable Cache-Control header in getServerSideProps for generated JSON file, then it works on dev server but not on production builds or set to no-cache, no-store, must-revalidate.
But Cache-Control works as expected when you visit the link directly or for generated html.
I'm running my own server.
To Reproduce
Create pages/about.js file with content like below
exportasyncfunctiongetServerSideProps({ res }){res.setHeader('Cache-Control','public, max-age=7200')return{props: {}};}exportdefaultfunction(){return<h1>About</h1>}
Start dev server and open any page other than about, then navigate to about page. Then you will see about.json in a browser inspector and it's Cache-Control header set to public, max-age=7200.
Build the project, and do the same as Step 3, but you'll see Cache-Control set to no-cache, no-store, must-revalidate
Expected behavior
I expect that Cache-Control header to be same as set in getServerSideProps either in dev or production build.
System information
OS: macOS
Browser: Chrome
Version of Next.js: 9.3.0
Additional context
I was able to reproduce the issue in a new next.js project.
The text was updated successfully, but these errors were encountered:
dulmandakh
changed the title
setting Cache-Control header in getServerSideProps on generated JSON is not working on production build
setting Cache-Control header in getServerSideProps on generated JSON is not working on production
Mar 12, 2020
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 30, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
Thank you for Next.js and it's 9.3 version, it's amazing.
Describe the bug
I'm trying to set reasonable Cache-Control header in getServerSideProps for generated JSON file, then it works on dev server but not on production builds or set to no-cache, no-store, must-revalidate.
But Cache-Control works as expected when you visit the link directly or for generated html.
I'm running my own server.
To Reproduce
Start dev server and open any page other than about, then navigate to about page. Then you will see about.json in a browser inspector and it's Cache-Control header set to public, max-age=7200.
Build the project, and do the same as Step 3, but you'll see Cache-Control set to no-cache, no-store, must-revalidate
Expected behavior
I expect that Cache-Control header to be same as set in getServerSideProps either in dev or production build.
System information
Additional context
I was able to reproduce the issue in a new next.js project.
The text was updated successfully, but these errors were encountered: