Full route cache helps your Next.js app load pages faster by saving the whole page output. This means users see content quickly without waiting for the server to build it every time.
Full route cache in NextJS
export const dynamic = 'force-static'; export default function Page() { return <main>Hello, this page is fully cached!</main>; }
Use export const dynamic = 'force-static' to tell Next.js to cache the entire route as static.
This works well with the new App Router in Next.js 13+.
export const dynamic = 'force-static'; export default function Home() { return <h1>Welcome to the cached home page!</h1>; }
export const dynamic = 'force-static'; export default function About() { return <p>About page content is cached and fast.</p>; }
This component uses dynamic = 'force-static' to cache the entire page output. When users visit, Next.js serves the cached HTML immediately without rebuilding.
export const dynamic = 'force-static'; export default function CachedPage() { return ( <main> <h1>Full Route Cache Example</h1> <p>This page is fully cached by Next.js.</p> </main> ); }
Full route cache works best for pages that do not change often.
If your page needs fresh data, consider using other caching strategies.
Remember to test your cached pages to ensure they show the correct content.
Full route cache saves the entire page output for faster loading.
Use export const dynamic = 'force-static' in your page component.
Best for mostly static pages to improve speed and reduce server work.
Practice
Solution
Step 1: Understand full route cache purpose
Full route cache stores the whole rendered page output to speed up loading.Step 2: Compare options with this purpose
Only "It saves the entire page output to serve faster on next visits." describes saving entire page output for faster serving.Final Answer:
It saves the entire page output to serve faster on next visits. -> Option AQuick Check:
Full route cache = saves full page output [OK]
- Thinking it only caches API data
- Confusing with disabling cache
- Assuming it caches only images
Solution
Step 1: Recall syntax for full route cache
Next.js usesexport const dynamic = 'force-static'to enable full route cache.Step 2: Check each option
Only "export const dynamic = 'force-static';" matches the correct syntax for full route cache.Final Answer:
export const dynamic = 'force-static'; -> Option CQuick Check:
Full route cache syntax = dynamic = 'force-static' [OK]
- Using 'force-dynamic' instead of 'force-static'
- Confusing cache control with dynamic export
- Setting revalidate to 0 disables caching differently
export const dynamic = 'force-static';
export default function Page() {
return <h1>Hello World</h1>;
}Solution
Step 1: Analyze the dynamic export value
The code setsdynamic = 'force-static', which enables full static caching.Step 2: Understand effect on page rendering
This means the page HTML is cached fully and served statically on all requests.Final Answer:
The page is fully cached and served statically on all requests. -> Option DQuick Check:
dynamic = 'force-static' means full static cache [OK]
- Thinking it disables caching
- Assuming partial caching of API only
- Confusing with dynamic rendering
export const dynamic = 'force-static'
export default function Page() {
return <div>Cached Page</div>;
}Solution
Step 1: Check syntax correctness
JavaScript allows omitting semicolons; no syntax error here.Step 2: Verify caching value and component
'force-static' is valid to enable full route cache; component can be normal function.Final Answer:
No error; code correctly enables full route cache. -> Option BQuick Check:
Code syntax and caching value are correct [OK]
- Assuming missing semicolon causes error
- Confusing 'force-static' with 'force-dynamic'
- Thinking component must be async
Solution
Step 1: Understand full route cache use case
Full route cache works best for mostly static pages to serve fast.Step 2: Handle dynamic widgets separately
Loading widgets client-side keeps page static cache intact while showing dynamic content.Step 3: Evaluate options
Setexport const dynamic = 'force-static'and load widgets client-side only. matches this approach; others either disable caching or cache dynamic parts incorrectly.Final Answer:
Set export const dynamic = 'force-static' and load widgets client-side only. -> Option AQuick Check:
Static page + client widgets = dynamic = 'force-static' [OK]
- Caching dynamic widgets server-side causing stale data
- Disabling cache unnecessarily
- Using force-dynamic which disables full route cache
Ready to prove it?
Pass the test and this pattern moves unknown
