-
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
Cache headers on 404 pages with getStaticProps #22579
Comments
Hi, i have the same problem. If we set the
Is it possible to have feedback? |
This is problematic when deploying a new version of an app behind a caching proxy/CDN (e.g. cloudflare). If a request comes in and is routed to the new server, the user's browser will request a given newly built chunk (e.g. https://example.com/_next/static/chunks/12345.js). If that request gets routed to the old server that does not have that chunk, the 404 response will get cached by the proxy/CDN and the app will be broken for subsequent visitors until the cache is manually cleared. It would be great to get this fixed! |
This issue is affecting our Next.js app – https://wormhole.app – which is uses a zero-downtime deployment system. During a new deployment, two version of the server, old and new, are running. If a request for a new chunk URL is routed to the old Next.js server, then a 404 will be returned, which will be cached by the user's browser (or Cloudflare). This leaves the site in a permanently broken state until the browser cache or Cloudflare cache is cleared. |
Fixes vercel#22579 This still needs more work / tests.
Had a look at this and it seems that curl resultsWithout `getStaticProps` on `pages/404.js`
Without `getStaticProps` requesting `/_next/`
With `getStaticProps` on `pages/404.js`
With `getStaticProps` requesting `/_next/`
|
@jhiesey Hi John, we are facing the exactly same issue as you described above. Did you find any solutions so far? Thanks! |
Or maybe somebody knows to which version of Next we should revert to not be facing this issue? Thanks! |
Hi, we are experiencing the exact same issue. Can anyone review and merge @timneutkens PR please? |
As a "workaround", we manually set the |
Hello @jhiesey & @tomsonpl! Did your issue get fixed with the merged changes from @timneutkens ? |
If I remember correctly, we just added the ''revalidate'' option (it wasn't there at first) and it never happened again. |
@tomsonpl, thank you for your reply! |
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. |
What version of Next.js are you using?
10.0.6
What version of Node.js are you using?
14.15.1
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Other platform
Describe the Bug
The 404 error page responds with the cache headers
cache-control: s-maxage=31536000, stale-while-revalidate
when the getStaticProps function is exported.This could be a problem when the resource is temporary unavailable.
Expected Behavior
The cache headers for the 404 responses should be
cache-control: public, max-age=0, must-revalidate
like when thegetStaticProps
function is not exported.To Reproduce
npx create-next-app
getStaticProps
npm run build && npm start
http://localhost:3000/_next/static/give-me-a-404-response
The text was updated successfully, but these errors were encountered: