-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Docs: Document caching mechanisms #52514
Conversation
docs/02-app/01-building-your-application/05-optimizing/01-caching.mdx
Outdated
Show resolved
Hide resolved
docs/02-app/01-building-your-application/05-optimizing/01-caching.mdx
Outdated
Show resolved
Hide resolved
@delbaoliveira Thanks for your great work! Could you please take a look at #52069? |
docs/02-app/01-building-your-application/04-caching/02-router-cache.mdx
Outdated
Show resolved
Hide resolved
docs/02-app/01-building-your-application/04-caching/03-data-cache.mdx
Outdated
Show resolved
Hide resolved
docs/02-app/01-building-your-application/04-caching/02-router-cache.mdx
Outdated
Show resolved
Hide resolved
### Opting out of Data Caching | ||
|
||
`fetch` requests are **not** cached if: | ||
|
||
- The `cache: 'no-store` is added to `fetch` requests. | ||
- The `revalidate: 0` option is added to individual `fetch` requests. | ||
- The `fetch` request is inside a Router Handler that uses the `POST` method. | ||
- The `fetch` request comes after the usage of `headers` or `cookies`. | ||
- The `const dynamic = 'force-dynamic'` route segment option is used. | ||
- The `fetchCache` route segment option is configured to skip cache by default. | ||
- The `fetch` request uses `Authorization` or `Cookie` headers and there's an uncached request above it in the component tree. |
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.
Need to verify if these cases are correct
Co-authored-by: Dominik Dorfmeister <[email protected]> Co-authored-by: Michael Novotny <[email protected]>
Co-authored-by: Michael Novotny <[email protected]>
Thank you @manovotny, @TkDodo and @alvarlagerlof for the feedback! 🙏🏼 |
Looking forward to reading these! :) |
It's also worth mentioning the Data Cache created by |
@delbaoliveira 🎉🎉🎉🎉🎉🎉Congrats Marge!🎉🎉🎉🎉🎉🎉 I was able to see the diagram now, but I think the React Memoization and the Data Cache positions are inverted. https://nextjs.org/_next/image?url=%2Fdocs%2Flight%2Fcaching-overview.png&w=1920&q=75&dpl=dpl_6jEE2o8UhNfkbiXNT6wnDf4UwJwt In fact, the Next.js' |
Follow up from #52514. We're still missing the static and dynamic diagram, it was missed in the PR to `front` to add the original diagrams. We'll need to get that in as well, could be here, or in a follow up.
Hey @koichik, Thank you! I hear your point about the implementation order. This is the limitation with a 2d graphic, I think it is slightly more important to show that Request Memoization is on the rendering server and the Data Cache is on a separate network. We have a similar challenge visualizing an initial visit request passing through the client-side Router Cache even though it wouldn't exist yet. |
This PR document the caching semantics in Next.js, how they interact, and what APIs affect them. We're also taking the opportunity to consolidate terminology, remove duplicate content, and update sections of the docs that relate to caching.
Documentation
Create a page to explain how Client and Server Components are rendered. Moved to this PR: docs: Rewrite Rendering Section and React Essentials Page #51579cache
generateStaticParams
being able to seed the Full Route CacheRelated PRs: