---
title: "Caching and Revalidation"
description: "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 immedia..."
last_updated: "2026-10-12T06:40:49.103345+00:00"
canonical_url: "https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/guide/how-to-guides/caching-and-revalidation"
---

## 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.

```mermaid
flowchart TD
    A[Visitor Requests Page] --> B{Is cached copy fresh?}
    B -- Yes --> C[Display Saved Content Instantly]
    B -- No --> D[Generate New Content & Update Cache]
    D --> E[Display Fresh Content]
```

---

## 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

| Concept | Plain Language Definition |
| :--- | :--- |
| **Cache** | A temporary storage area that holds a copy of your rendered pages so they load lightning-fast for users. |
| **Stale Data** | Information that is outdated because the source content has changed since the cache was last created. |
| **Revalidation** | The 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.

## Related

- [Data Fetching and Mutation](https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/guide/core-features/data-fetching-and-mutation)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/llms.txt) for all pages in this wiki.
