Confusing explantion of Nextjs caching and rendering. #72230
Replies: 1 comment 3 replies
-
You can expect quite a bit of material to catch up to the new standard, on the coming weeks. So for question 1, you need to allow some time for the docs to align behind the new behavior of Next 15, which is not caching by default. As for question 2. Often when you work with databases, their APIs do not use the fetch API, but other means to query the data, and because of that, they are not cached by Next.js. That has nothing to do with pre-rendering. Pre-rendering just needs to collect the data, during build time. If a route/page is statically pre-rendered, and has no means to incrementally refresh itself (ISR), or it is not generated on demand, fully dynamic, then you'd need to rebuild your app, every time you'd want to show new/updated data. |
Beta Was this translation helpful? Give feedback.
-
I am really confused about nextjs caching and rendering behavior after reading the recent doc of nextjs. The explanation of caching and rendering in different sections of docs conflict with each other.
For example:
fetch
api reference states nextjs fetch request response no longer cached by default. doc referenceBut in data fetching and caching docs states, "The response from fetch will be automatically cached." doc reference
Dynamic APIs
anywhere else in this route, it will be prerendered during next build to a static page. The data can then be updated using Incremental Static Regeneration. doc referenceQuestion 1: if database response i not cached then how it can be prerendered?
But Caching data with an ORM or Database states "You can use the
unstable_cache
API to cache the response to allow pages to be prerendered when running next build." doc referenceQuestion 2: If fetching data with an ORM or database route is prerendered if I don't use a
Dynamic APIs
then why i do needunstable_store
to make the route prerendered?Again nextjs lean chapter 10 states "And in Next.js, if you call a dynamic function in a route (like querying your database), the entire route becomes dynamic." doc reference
Beta Was this translation helpful? Give feedback.
All reactions