🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

How to disable cache in Sanity.io for immediate reflection of changes made in the studio on the blog.

7 replies
Last updated: Apr 12, 2024
Hi, all!How do I disable cache?

Changes I make in the studio aren't reflected immediately on the blog.
I've set useCdn to false in the code, and the result of client.config() printout is as follows:

console.log('client: ', client.config());

client:  {
  apiHost: '<https://api.sanity.io>',
  apiVersion: '2023-03-25',
  useProjectHostname: true,
  stega: { enabled: false },
  projectId: 'seu6wqtr',
  dataset: 'production',
  useCdn: false,
  isDefaultApi: true,
  url: '<https://seu6wqtr.api.sanity.io/v2023-03-25>',
  cdnUrl: '<https://seu6wqtr.apicdn.sanity.io/v2023-03-25>'

Apr 12, 2024, 1:01 AM
I would think it depends on what framework you are using in the frontend for your blog.
Apr 12, 2024, 5:13 AM
My frontend is based on next.js and Vercel.
Apr 12, 2024, 5:22 AM
If you are using the new app router in next js it will automatically cache all your data using force-cache. To get fresh data you have a few options depending on your needs. If the project is small ish it's easy to just add a {cache: "no-store"} direction to your fetch query.
It would look something like this...

groq`*[_type == “project” &amp;&amp; slug.current == $slug][0]`, {}, { cache: "no-store" }
Apr 12, 2024, 5:30 AM
Like I said there are other options that you can find from the next app router caching documentation.
Apr 12, 2024, 5:31 AM
Okay, Thank you very much!Let me try it.
Apr 12, 2024, 5:38 AM
user U
this might help
Apr 12, 2024, 10:11 AM
user A
Apr 12, 2024, 2:48 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?