๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with cache not reflecting changes in response of query in Next.js and Sanity v3.

4 replies
Last updated: Sep 29, 2023
Hi all!I have an issue regarding cache. Im using Sanity v3 embedded in Next.js 13 and a very simple schema with a Post containing a title, image and portable text - pretty much like the example apps. Whenever i make any changes, they are not reflected in the in response of the query. I've tried both enabling and disabling the useCdn prop of
createClient from the next-sanity library, but so far it has made no change. Any ideas what I need to do to? Thanks!
Sep 29, 2023, 11:50 AM
Hey
user U
. Although this will sound like a simple question, are you publishing the document? The queries should return the correct result for non-drafts, and it should be Next caching your page in case you're using something like Next's ISR .You can also
review caching strategies , such as opting out of caching through
{ cache: 'no-store' }
Sep 29, 2023, 12:55 PM
It was in fact next causing the issue. Exporting const dynamic = 'force-dynamic' solved it.Thank you
๐Ÿ™‚
Sep 29, 2023, 12:59 PM
Awesome. Glad it's sorted. Have a great day
Sep 29, 2023, 1:01 PM
You too!
Sep 29, 2023, 1:10 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?