Caching for Next.jss
Caching in Next.js is the set of stores that avoid repeating work, such as cached fetch results, prerendered pages and the browser-side router cache. Revalidation by time or by tag decides when entries refresh. Built-in image, font and metadata features also reduce payload size and improve search previews.
Stage: Data and Caching · Part of the Next.js roadmap · Last reviewed 19 November 2026
What to learn in Caching
- Name the cache layers Next.js uses and what each one stores
- Set time-based revalidation on a fetch or a route segment
- Invalidate cached data on demand with revalidateTag or revalidatePath
- Serve responsive images using the Image component with width and height
- Load fonts with next/font and define page titles through the metadata API
Caching interview questions
What is the difference between time-based and on-demand revalidation in Next.js?
Time-based revalidation marks cached data stale after a set number of seconds and refreshes it on the next request. On-demand revalidation clears entries immediately when you call revalidateTag or revalidatePath, usually after a mutation or a webhook from a CMS.
Why use next/image instead of a plain img tag?
The Image component resizes and converts pictures to modern formats, serves sizes suited to the device, lazy loads below-the-fold images, and requires dimensions so the layout does not shift. These behaviours improve loading speed and Core Web Vitals without manual work.
Where Caching fits in the Next.js roadmap
Caching belongs to the Data and Caching stage (intermediate level), which takes about 16 hours. Fetch what you need.
Other units in this stage
Back to the full Next.js roadmap