Caching reference
How islands are cached in each host mode, what stale-if-error keeps, and what blocking costs.
Public islands are cached. Private islands never are. For the task flow, see Caching.
App Router, legacy mode (no cacheComponents)
The adapter fetches the envelope with Next's fetch cache (next: { revalidate, tags }). revalidate defaults to islands.revalidate (60 seconds). Tags are nf:<remote> and nf:<remote>:<island>.
- The page can be static (ISR).
- A failed regeneration keeps the last good envelope (Stale-if-error). Without one, the fallback stays until the next regeneration.
- A
200with an invalid envelope (NF-004) is cached forrevalidateseconds. Non-2xx responses, timeouts and network errors are not cached. dynamicfetches on every request (cache: 'no-store') and makes the route dynamic.
App Router, cacheComponents
The envelope comes from a 'use cache' function with the same tags.
- A failed fetch is cached with the profile
{ stale: 30, revalidate: 5, expire: 600 }. The page stays static (○) and regenerates within about 5 seconds. - The island shows its last good envelope, or
errorFallbackwithout one. - A working island stays cached for its
revalidate. RemoteIslandrenders its own<Suspense>. A private island withblockingdoes not.- Your own
'use cache'component around aRemoteIslandgets the same failure profile when the island fails. Keep it inside<Suspense>.
Next 16 leaves an entry with expire under 5 minutes out of a static prerender. A dynamic hole would then make Next stop regenerating the page. That is why failures stay in the static shell.
The Next 16 scaffold defaults
create-next-app 16.4.6 sets cacheComponents: true and partialPrefetching: true.
- A page with only public islands stays static, also when a remote fails.
- A private island is a dynamic hole in its own
<Suspense>, unless it usesblocking. - Next 16 keeps visited routes mounted but hidden, so an island can stay mounted in the background.
partialPrefetchingworks with private islands.
On Next 15, the adapter uses the legacy cache. withNextFederation throws NF-002 if cacheComponents, experimental.cacheComponents or experimental.dynamicIO is set.
Stale-if-error
A cached public island whose fetch fails (NF-003, NF-004, NF-005, NF-007, NF-008) renders the last good envelope for the same remote, island, props and host context. The failure is still logged and emitted as island:error.
- The envelope is kept for at least an hour, or twice
revalidate. - Envelopes live in the server process's memory: at most 500 and 50 MiB.
- A fresh process, a new serverless instance or
next buildhas none, so the fallback renders. - Private and
dynamicislands are never served stale. - A
404withContent-Type: application/jsoncounts as a deliberate removal and renders the fallback at once. That includes a gateway's{"message":"Not Found"}. - A
404with another content type, such as a proxy's HTML page, is served stale. - Redirects are refused, and a body over
islands.maxBytes(5 MiB) stops the read with no retry (NF-007). - On an HTML or non-protocol
404, the log asks whether the origin is an island remote. A Next.js app cannot be one.
Private islands
The token never enters a cache key, the HTML or the RSC payload (Identity). Without cacheComponents, a private island makes the route dynamic. With it, the island is a dynamic hole.
blocking: the island in the first HTML
blocking renders the island without its own <Suspense>, so its HTML is in the first flush (Getting Started).
| Host | Route config | next build marker |
|---|---|---|
No cacheComponents (Next 16 or 15) | none (instant is refused) | ƒ (already dynamic) |
cacheComponents | export const instant = false in the page | ƒ, not ◐ |
- The whole route becomes per-request. With
cacheComponents, it loses its static shell. - Without
instant = false,next buildfails with "uncached or runtime data during prerendering". An ancestor layout withinstant = truecauses the same error. - Put
instant = falsein the page file. In a layout alone,next devstill logs the instant-navigation check. - Without
cacheComponents,next buildrefusesinstant. - The response waits for the remote, up to
timeoutMs(3 seconds by default). - A failing remote renders
errorFallbackin place, and the page answers200. - If
getIdentityor token minting throws, the error reacheserror.tsx. Returnnullinstead. - A
<Suspense>above the island, such asloading.tsx, streams it again. - Without its own boundary, a hydration error elsewhere can re-render the island on the client.
- Public islands on the page stay cached but render per request.
blockingon a public island throwsNF-002.
Pages Router
getIslandProps fetches on every call. In getStaticProps, the page's revalidate is the cache. A failed fetch returns the last good envelope with stale: true, or envelope: null.
return {
props: { banner },
revalidate: banner.envelope && !banner.stale ? 60 : 5,
}Events for cached islands
island:fetch and island:error describe the fetch that produced the envelope. A page served from cache emits no new events. Do not use event counts as page views.
Build cache and remote retention
A cached envelope pins a remote build at /b/<buildId>/…. Your host cache (build cache, ISR pages, CDN) must not outlive the remote's retention.
- Otherwise the remote answers
410withNF-023, and the island stays inert. nf-servekeeps the newest 3 builds or any under 24 hours old.- Keep retention at least as long as your longest host cache lifetime. See Deployment.