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
Next.js documentation is uncleared often,
For example, Automatic Invalidation Period for Router Cache https://nextjs.org/docs/app/deep-dive/caching#client-side-router-cache
documentation states, that
1)
With the Router Cache:
Layouts are cached and reused on navigation (partial rendering).
Loading states are cached and reused on navigation for instant navigation.
Pages are not cached by default, but are reused during browser backward and forward navigation. You can enable caching for page segments by using the experimental staleTimes config option.
2)
Automatic Invalidation Period: The cache of layouts and loading states is automatically invalidated after a specific time.
3)
Good to know: The experimental staleTimes config option can be used to adjust the automatic invalidation times mentioned above.
4) https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching
Only the shared layout, down the rendered "tree" of components until the first loading.js file, is prefetched and cached for 30s
What is that means?
1)page segment is not cached, if no staleTimes defined, if defined - page segment uses this staleTimes invalidation period - right or wrong?
2)layout/loading is cached using default invalidation period, and staleTimes has no affect on it - right or wrong?
3)how is prefetched data for loading/layout affected by Automatic Invalidation Period and stateTimes?
Next question https://nextjs.org/docs/app/api-reference/functions/cacheLife
The cacheLife function is used to set the cache lifetime of a function or component
stale | number | Duration the client should cache a value without checking the server.
Dose it mean, that Router Cache with RSCP cache also contains separate data cache for cached parts and this cached data revalidate separately from RSCP?
What if data cached expire? Is the affected RSCP cache expired too, no matter did Invalidation Period come or not?
Next question https://nextjs.org/docs/app/deep-dive/caching#client-side-router-cache
Layouts are cached and reused on navigation
The cache of layouts and loading states is automatically invalidated after a specific time
I have root layout dynamic via connection
i have about page with dynamic layout for it via connection
when i navigate from /about to / using Link with prefetch ={false}
according to doc, dynamic root layout must rerender, because is not cached in router cache (it is dynamic and link with prefetch = false)
but console log don't show that root layout rerenders, only /about layout. Why is that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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
Next.js documentation is uncleared often,
For example, Automatic Invalidation Period for Router Cache
https://nextjs.org/docs/app/deep-dive/caching#client-side-router-cache
documentation states, that
1)
With the Router Cache:
Layouts are cached and reused on navigation (partial rendering).
Loading states are cached and reused on navigation for instant navigation.
Pages are not cached by default, but are reused during browser backward and forward navigation. You can enable caching for page segments by using the experimental staleTimes config option.
2)
Automatic Invalidation Period: The cache of layouts and loading states is automatically invalidated after a specific time.
3)
Good to know: The experimental staleTimes config option can be used to adjust the automatic invalidation times mentioned above.
4)
https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching
Only the shared layout, down the rendered "tree" of components until the first loading.js file, is prefetched and cached for 30s
What is that means?
1)page segment is not cached, if no staleTimes defined, if defined - page segment uses this staleTimes invalidation period - right or wrong?
2)layout/loading is cached using default invalidation period, and staleTimes has no affect on it - right or wrong?
3)how is prefetched data for loading/layout affected by Automatic Invalidation Period and stateTimes?
Next question
https://nextjs.org/docs/app/api-reference/functions/cacheLife
The cacheLife function is used to set the cache lifetime of a function or component
stale | number | Duration the client should cache a value without checking the server.
Dose it mean, that Router Cache with RSCP cache also contains separate data cache for cached parts and this cached data revalidate separately from RSCP?
What if data cached expire? Is the affected RSCP cache expired too, no matter did Invalidation Period come or not?
Next question
https://nextjs.org/docs/app/deep-dive/caching#client-side-router-cache
Layouts are cached and reused on navigation
The cache of layouts and loading states is automatically invalidated after a specific time
I have root layout dynamic via connection
i have about page with dynamic layout for it via connection
when i navigate from /about to / using Link with prefetch ={false}
according to doc, dynamic root layout must rerender, because is not cached in router cache (it is dynamic and link with prefetch = false)
but console log don't show that root layout rerenders, only /about layout. Why is that?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions