Skip to main content
doc0blade47/next.jsdocumentation home
Sign in

Caching and Revalidation

Last updated Oct 12, 2026100% grounded

Overview

Understanding Content Caching and Refreshing

When you visit a website or use an application, loading pages instantly is important. To make this happen, the system uses caching—a process that saves a copy of your content so it can load immediately on future visits without having to rebuild it from scratch.

However, when you update your information, you want your visitors to see the latest version right away rather than an older, saved copy. This page explains how you can control how long your content stays saved, and how to refresh stale (outdated) data instantly when changes happen.


How to Control Caching and Data Refresh

1. Choose a Caching Strategy

Decide how long your content should remain fresh before the system checks for updates. You can set a specific time limit (measured in seconds) or keep content cached indefinitely until you manually trigger an update.

2. Configure Your Content Lifespan

Open your content or page settings and locate the cache duration option. Enter the maximum amount of time you want the system to hold onto the saved copy before automatically fetching a fresh version.

3. Trigger On-Demand Revalidation

When you make important updates that cannot wait for the timer to expire, you can force the system to clear the old cache immediately. This is known as on-demand revalidation (or refreshing on demand).

  • Use your application's update trigger, background webhook, or manual refresh button to tell the system that the underlying data has changed.
  • The system will discard the old saved copy and generate a fresh one the very next time someone requests it.

Key Concepts

ConceptPlain Language Definition
CacheA temporary storage area that holds a copy of your rendered pages so they load lightning-fast for users.
Stale DataInformation that is outdated because the source content has changed since the cache was last created.
RevalidationThe process of checking for updates and refreshing the cached copy with the newest available data.

Note

Setting your cache duration to a longer time improves speed and reduces server load, but means visitors might see updates slightly later. Shorter durations ensure real-time accuracy at the cost of extra processing work.

Tip

If you publish a major correction or breaking news update, use on-demand revalidation rather than waiting for your scheduled timer to expire so your users see the fix instantly.

Warning

Avoid setting your cache expiration times to zero everywhere unless you specifically need real-time data on every single click, as this can slow down performance and increase server costs.

Was this page helpful?