Caching Q&A, Not Covered by Docs #88272
Unanswered
magnusriga
asked this question in
Help
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I have read the docs on the new Next.js 16 caching model, and all related documentation. I am left with the below questions.
I hope this Q&A, once answered by someone with more insight than myself, can severe as an additional guide for users in the future.
Relevant Official Docs
Notes
Q&A
QUESTION
fetch(..), is it also necessary cache the component containing that function, withuse cache, or will components automatically be cached when all their containing data fetches are cached?use cache, is it necessary to also cache components higher up in tree withuse cache, for the whole page and/or layout to be cached?ANSWER
QUESTION
use cacheinside a<Suspense>ed component, does it defer rendering of the inner component until request time, or does it cache the component and serve it from the Full Route Cache immediately upon request?Suspensearound a Server Component ("SC") that callsfetch, when the SC itself declaresuse cache?ANSWER
QUESTION
SuspensearoundMyComponent.MyComponentcalls Dynamic content functiongetUsers(not Runtime data), which callsfetch(..).getUsersis marked withuse cache, to cache its result.MyComponentbe rendered runtime, or included in static shell?ANSWER
QUESTION
dynamic = "force-dynamic"is not needed, all pages are dynamic by default.ANSWER
QUESTION
QUESTION
ANSWER
QUESTION
revalidateTags(..), pages from the build-time cache might be re-rendered and then cached again. Are they then cahced on disk, in the.nextdirectory, like they were on build, or are they now placed in the in-memory cache instead?ANSWER
QUESTION
ANSWER
QUESTION
cacheLife: Definesstale, i.e. client-side cache duration, which is used alongsideuse cache.staleTimes?staleTimes, so we do not have to setcacheLifein everypagecomponent?cacheLife.stalein already pre-rendered components, i.e. nouse cache, to enable Router cache for "static" pages, likestaleTimes.static?cacheLifein dynamic components, i.e. nouse cachebut accesses Dynamic | Non-Deterministic data, to enable Router cache for "dynamic" pages, likestaleTimes.dynamic?ANSWER
QUESTION
sessionId, the docs states there will be one cache entry persessionIdvalue, since args are part of the cache key, and must therefore be mindful of what props we pass to cached components, to avoid bloating the cache (source).sessionId, should in most cases not be passed to cached components that live within runtime data components, even though this main docs example does exactly that: https://nextjs.org/docs/app/getting-started/cache-components#with-runtime-dataANSWER
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions