Selective Cache Purging & NextJS preview mode

I’ve got a NextJS site which I’ve built, it’s using StoryBlok as a headless CMS, and using the Storyblok-Javascript-Client to handle requests.

GitHub: GitHub - geometricpanda/geometricpanda-blog
Netlify Domain:

When publishing a change in StoryBlok i’m not seeing it reflected on the site at run-time, so i started debugging it.

I’m aware for local NextJS development that StoryBlok caches content, so I created an API endpoint which tells StoryBlok to purge it’s cache: geometricpanda-blog/revalidate.ts at main · geometricpanda/geometricpanda-blog · GitHub

Next within that endpoint I’ve also told NextJS to revalidate that path.

I’ve then hooked up Storyblok webhooks to that revalidate api and made a change to the content (Storyblok passes the changed content ID via the webook).

But it’s not updating on the site which leads me to believe that this is a Netlify cache causing this.

I know I could trigger a complete cache purge programatically to resolve this, and indeed it does update when i do this, but it’d be much better for my use-case if i could selectively purge the single page cache.

Taking this a step further is the NextJS preview mode with res.setPreviewData({}); in a preview API, as documented here: Advanced Features: Preview Mode | Next.js

Unfortunately this was also suffering from the same problem of the cache not refreshing.

So i guess what i’m asking is:

  • Is there a way to selectively purge URL caches? such as curl -x PURGE (or similar)
  • Is there a way to get Netlify to respect the preview mode header?


Hey @jimdrury,

Regarding point 1, are you talking about On Demand ISR? If yes, you should probably follow this: Question - timeline to support on-demand Incremental Static Regeneration (ISR) on Netlify?. If not, could you please describe in more detail? Do you wish to purge cache for any URL on your site - regardless of whether it’s using Next.js or not?

Regarding 2, you should be able to utilize preview mode on Netlify. Can you outline what exactly isn’t working or where you are unable to enable it? Any error messages or additional details you can share would be beneficial for us to investigate this further.