0
0
NextJSframework~8 mins

Full route cache in NextJS - Performance & Optimization

Choose your learning style9 modes available
Performance: Full route cache
HIGH IMPACT
Full route cache improves page load speed by serving pre-rendered pages instantly, reducing server work and network delays.
Serving a Next.js page quickly to users
NextJS
export async function getStaticProps() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return { props: { data }, revalidate: 3600 };
}

export default function Page({ data }) {
  return <div>{data.content}</div>;
}
Page is statically generated and cached, served instantly on requests, and revalidated periodically.
📈 Performance GainReduces server response time to near zero on cache hit; improves LCP by 300-500ms.
Serving a Next.js page quickly to users
NextJS
export async function getServerSideProps() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return { props: { data } };
}

export default function Page({ data }) {
  return <div>{data.content}</div>;
}
Page is rendered on every request causing slow server response and delayed page load.
📉 Performance CostBlocks rendering for 200-500ms depending on API speed; increases TTFB (Time to First Byte).
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Server-side rendering on every requestModerate (depends on data)Multiple reflows due to delayed contentHigh paint cost due to slow content arrival[X] Bad
Static generation with full route cacheMinimal (pre-rendered HTML)Single reflow on initial paintLow paint cost, fast content display[OK] Good
Rendering Pipeline
Full route cache serves pre-built HTML directly, skipping server rendering and data fetching on each request.
Server Rendering
Network
First Paint
Largest Contentful Paint
⚠️ BottleneckServer Rendering and Network latency
Core Web Vital Affected
LCP
Full route cache improves page load speed by serving pre-rendered pages instantly, reducing server work and network delays.
Optimization Tips
1Use static generation with caching to serve pages instantly.
2Avoid server-side rendering on every request for better LCP.
3Set appropriate revalidation times to keep cache fresh without slowing responses.
Performance Quiz - 3 Questions
Test your performance knowledge
How does full route caching affect Largest Contentful Paint (LCP) in Next.js?
AIt increases LCP by adding extra server processing.
BIt reduces LCP by serving pre-rendered pages instantly.
CIt has no effect on LCP.
DIt only affects input responsiveness, not LCP.
DevTools: Performance
How to check: Record a page load in DevTools Performance panel and look at the Time to First Byte and Largest Contentful Paint timings.
What to look for: Fast TTFB and early LCP indicate effective full route caching.