Skip to Content
DeploymentCache Revalidation

Cache Revalidation

When a client publishes content, you can have Vard immediately invalidate your Next.js cache so changes appear without waiting for the next rebuild or revalidation interval.

How it works

  1. Client clicks Publish in the Vard dashboard
  2. Vard calls your revalidation webhook URL
  3. Your Next.js app receives the request and calls revalidatePath() or revalidateTag()
  4. The cache is cleared and the next request gets fresh content

Setting up the webhook

1. Create a revalidation route

app/api/revalidate/route.ts
import { revalidatePath } from "next/cache"; import { NextResponse } from "next/server"; export async function POST(req: Request) { const secret = req.headers.get("x-revalidate-secret"); if (secret !== process.env.REVALIDATE_SECRET) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } revalidatePath("/", "layout"); // revalidate all pages return NextResponse.json({ revalidated: true }); }

2. Add a revalidation secret

.env.local
REVALIDATE_SECRET=your_random_secret_here

3. Register the webhook URL in Vard

In your workspace, go to Settings → Deployment → Revalidation Webhook URL and enter:

https://yourdomain.com/api/revalidate

Vard will POST to this URL on every publish, with your secret in the x-revalidate-secret header.

Revalidating specific paths

Instead of revalidating all pages, you can target specific routes:

revalidatePath("/"); // home page revalidatePath("/about"); // about page revalidatePath("/[slug]", "page"); // all pages matching a dynamic route

Or use cache tags for fine-grained control:

// In your page: fetch("...", { next: { tags: ["content"] } }); // In your webhook handler: import { revalidateTag } from "next/cache"; revalidateTag("content");
Last updated on
Vard SDK Documentation