#Next 13 Invalidating Cache with Headless CMS

1 messages · Page 1 of 1 (latest)

neon summitBOT
#

Hi @hardy lotus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

It seems like you're trying to use Incremental Static Regeneration (ISR) with on-demand revalidation. Based on the provided extracts, there are a few things you should check:

  1. Make sure your upstream data provider (Strapi) does not have caching enabled by default. You might need to disable it (e.g., useCdn: false), otherwise, a revalidation won't be able to pull fresh data to update the ISR cache source (https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration).

  2. In your getStaticProps function, you should set the revalidate property to specify the number of seconds after which a page re-generation can occur. For example, revalidate: 10 means that Next.js will attempt to re-generate the page at most once every 10 seconds source (https://nextjs.org/docs/api-reference/data-fetching/get-static-props).

  3. Make sure you're calling the revalidate() function on the exact path that you want to be revalidated. For example, if you have pages/blog/**slug].js and a rewrite from /post-1 -> /blog/post-1, you would need to call res.revalidate('/blog/post-1') [source** (https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration).

  4. Ensure that the webhook from your headless CMS is correctly set up to trigger the revalidation API when content is created or updated source (https://vercel.com/templates/next.js/nextjs-blog-preview-mode).

#

If you've checked all these points and the issue persists, it might be related to something specific to Next.js 13 that is not covered in the provided extracts. In that case, I recommend checking the Next.js documentation (https://nextjs.org/docs) and GitHub issues (https://github.com/vercel/next.js/issues) for any updates or known issues.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Get started with Next.js in the official documentation, and learn more about all our features!

GitHub

The React Framework. Contribute to vercel/next.js development by creating an account on GitHub.