Concept Flow - Full route cache
User requests a route
Check if route cached
Serve cached
Return response
Cache new route if rendered
This flow shows how Next.js checks if a route is cached, serves it if yes, or renders and caches it if no.
export const dynamic = 'force-static'; export default function Page() { return <h1>Hello, cached route!</h1>; }
| Step | Action | Cache Check | Render Action | Cache Update | Response |
|---|---|---|---|---|---|
| 1 | User requests /page | Cache miss | Render page component | Cache /page content | Send rendered HTML |
| 2 | User requests /page again | Cache hit | Skip rendering | No cache update | Send cached HTML |
| 3 | User requests /other | Cache miss | Render /other component | Cache /other content | Send rendered HTML |
| 4 | User requests /page again | Cache hit | Skip rendering | No cache update | Send cached HTML |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 |
|---|---|---|---|---|---|
| cache['/page'] | empty | cached content | cached content | cached content | cached content |
| cache['/other'] | empty | empty | cached content | cached content | cached content |
Full route cache in Next.js: - Checks if route HTML is cached on request - If cached, serves cached HTML immediately - If not cached, renders route, caches output, then serves - Improves performance by avoiding repeated rendering - Use export const dynamic = 'force-static' to enable full route caching