#static generation and not-found page
1 messages · Page 1 of 1 (latest)
Hi @jaunty charm. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, it is possible to opt out of the Full Route Cache in Next.js, which means you can dynamically render components for every incoming request. This can be achieved in several ways:
-
Using a Dynamic Function: This will opt the route out from the Full Route Cache and dynamically render it at request time. The Data Cache can still be used.
-
Using the
dynamic = 'force-dynamic'orrevalidate = 0route segment config options: This will skip the Full Route Cache and the Data Cache. Meaning components will be rendered and data fetched on every incoming request to the server. The Router Cache will still apply as it's a client-side cache. -
Opting out of the Data Cache: If a route has a
fetchrequest that is not cached, this will opt the route out of the Full Route Cache. The data for the specificfetchrequest will be fetched for every incoming request. Otherfetchrequests that do not opt out of caching will still be cached in the Data Cache. This allows for a hybrid of cached and uncached data.
However, it's important to note that you cannot opt out of the Router Cache. You can only opt out of prefetching by setting the prefetch prop of the <Link> component to false. This will still temporarily store the route segments for 30s to allow instant navigation between nested segments, such as tab bars, or back and forward navigation. Visited routes will still be cached.