Next.js Discord

Discord Forum

SWR with ISR/On demand revalidation?

Unanswered
Labrador Retriever posted this in #help-forum
Open in Discord
Labrador RetrieverOP
Hey!

The pages router used stale while revalidate, meaning that it would load a cached stale page instantly for a visitor of the site and once cache has been rebuilt with the updated data, only then it would show that to subsequent visits.

The app router, when using ISR and on demand revalidation (using revalidatePath/revalidateTag), when a user visits the page and the data has changed, they get a server rendered page with the updated data, but this introduces lag in the page navigation, while pages router with serving the cached stale pages instantly - didn't.

Is there a way to use the app router in a way that:

1. You're able to revalidate on demand, using revalidatePath/Tag.
2. If a user visits a page that has been marked as to be revalidated, they still get an instant response with the stale old cached page.
3. Once cache for that page has been rebuilt - for subsequent visits show the updated page.

0 Replies