Revalidation Basics

This page perfoms a fetch on the server to get a random article from Wikipedia. The fetched data is then cached with a tag named "randomWiki" and a maximum age of 60 seconds.

const url = 'https://en.wikipedia.org/api/rest_v1/page/random/summary';

async function RandomArticleComponent() {
const randomArticle = await fetch(url, {
next: { revalidate: 60, tags: ['randomWiki'] }
});
// ...render
}

After the set time has passed, the first request for this page would trigger its rebuild in the background. When the new page is ready, subsequent requests would return the new page - see stale-white-revalidate.

Alternatively, if the cache tag is explicitly invalidated by revalidateTag('randomWiki'), any page using that tag would be rebuilt in the background when requested.

In real-life applications, tags are typically invalidated when data has changed in an external system (e.g., the CMS notifies the site about content changes via a webhook), or after a data mutation made through the site.

For this functionality to work, Next.js uses the fine-grained caching headers available on Netlify - but you can use these features on basically any Netlify site!

Redya
River in Russia

The Redya is a river in Kholmsky, Poddorsky, Starorussky, and Parfinsky Districts of Novgorod Oblast in Russia. It is a left tributary of the Lovat. It is 146 kilometres (91 mi) long, and the area of [...]

From Wikipedia