đź”® Sanity Create is here. Writing is reinvented. Try now, no developer setup

Revalidate() a Page for SSG like Next.js - Invalidate Sanity CDN Cache

4 replies
Last updated: Jul 20, 2022
nextjs has this cool new feature to revalidate() a page for SSG, which makes it possible to update a single page once the data has changed. So I'm wondering if there is some way to invalidate the sanity CDN cache? Currently, if I have useCdn set to true, the revalidate() option in nextjs just pulls the stale data, currently I can't use the cdn at all because of this limitation.
Jul 20, 2022, 3:41 PM
Hmm, maybe using the CDN is just a bad idea for SSG.
Jul 20, 2022, 3:47 PM
user S
and I discussed it at length in the recent past and our general recommendation is that you shouldn’t use the Sanity CDN in a Next.js setup which uses dynamic revalidation.
Jul 20, 2022, 7:58 PM
user L
! The cache invalidates any time you publish an edit to a non-draft document, so editing/publishing the new content you're trying to pick up with your
. But
user F
's recommendation here is spot on.
Jul 20, 2022, 8:00 PM
Awesome, thanks. Glad to have the confirmed.
Jul 20, 2022, 8:01 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?