#Dynamic Rendering

1 messages · Page 1 of 1 (latest)

ancient knot
#

are dynamic rendered routes cached on the server?

odd nexusBOT
#

Hi @ancient knot. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

No, dynamic routes are not cached on the server by default. Dynamic routes are rendered at request time, and not cached. This is useful when a route has data that is personalized to the user or has information that can only be known at request time, such as cookies or the URL's search parameters. However, you can have dynamically rendered routes that have both cached and uncached data. This is because the React Server Component (RSC) Payload and data are cached separately, allowing you to opt into dynamic rendering without worrying about the performance impact of fetching all the data at request time [source (https://nextjs.org/docs/app/building-your-application/rendering/server-components)].

In contrast, static routes are cached by default. The default behavior of Next.js is to cache the rendered result (React Server Component Payload and HTML) of a route on the server. This applies to statically rendered routes at build time, or during revalidation [source (https://nextjs.org/docs/app/building-your-application/caching)].

It's also worth noting that Next.js has a Router Cache, an in-memory client-side cache that stores the React Server Component Payload, split by individual route segments, for the duration of a user session. This cache applies to both statically and dynamically rendered routes [source (https://nextjs.org/docs/app/building-your-application/caching)].

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@ancient knot kapa.ai is still learning and improving, please let us know how it did by reacting below