Issue with changes not showing up on production deployment without redeploying

23 replies
Last updated: May 31, 2023
Hey all, I having an issue : changes made in studio show up on my local deployment, but not on the production deployment(unless i redeploy) could someone help me out?
AI Update

This is a common caching issue! Your content changes show up locally because your dev environment fetches fresh data on every request, but production uses cached/static pages. Here's what's happening and how to fix it:

The Problem

Your production site is serving cached static pages that were generated at build time. When you make changes in Sanity Studio, those changes exist in your Content Lake, but your production site doesn't know to fetch the updated content until you redeploy (which regenerates all pages).

Solutions

If you're using Next.js, add a revalidate option to automatically refresh pages periodically:

// For App Router (Next.js 13+)
const posts = await sanityFetch({
  query: POSTS_QUERY,
  revalidate: 60, // Revalidate every 60 seconds
})

// For Pages Router
export async function getStaticProps() {
  // Your data fetching
  return {
    props: { /* your props */ },
    revalidate: 60 // Regenerate page every 60 seconds
  }
}

This means after you make changes in Studio, they'll appear on production within your revalidation window (e.g., 60 seconds). Learn more about ISR with Sanity.

2. On-Demand Revalidation - Best for immediate updates

For instant updates, use Sanity Functions (recommended) or webhooks with on-demand revalidation. When content changes in Studio, it triggers a revalidation:

// API route for revalidation
export default async function handler(req, res) {
  await res.revalidate('/path-to-update')
  return res.status(204).send('No Content')
}

Sanity Functions are the modern approach for this - they run serverless within Sanity and can trigger revalidation without needing external hosting.

3. Disable Sanity CDN in Production

When using ISR, set useCdn: false in your Sanity client config to ensure you're fetching fresh data during revalidation, not cached data from Sanity's CDN:

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'production',
  useCdn: false, // Important for ISR
  apiVersion: '2024-01-01',
})

4. Consider Live Content API

For real-time updates without manual revalidation, check out Sanity's Live Content API which works with Next.js, Nuxt, SvelteKit, and Astro.

Recommendation

The most common approach is ISR with time-based revalidation for a good balance between performance and freshness. Choose your revalidation interval based on how quickly you need changes to appear:

  • Frequently updated content (blog posts, products): 60 seconds
  • Rarely changing content (terms, about pages): 3600+ seconds

For critical content that needs immediate updates (like fixing typos), combine time-based ISR with on-demand revalidation using Sanity Functions.

Hmm...if your production deploy is a static site, as normal, it would have to be rebuilt each time you wanted to show results of editing in the Studio.
A redeploy would do that -- so does this picture sound a fit?
i've used export const dynamic = 'force-dynamic' on most of the pages, are there other settings required for enabling ssr? (im fairly new to next)
thank you for your reply btw!
well, not a next-pert, and it's late, but that sounds reasonable until someone else may clarify. The other possibility would seem that your production server is looking at a different Sanity dataset than your local, might check that?
Just checked, i currently only have 1 dataset
Is this a long-term situation, or maybe just for a few minutes after you update? Because then it could be that you've got the productiron server looking at the Content CDN, instead fo the Content API, and the delay would be for the update interval of the CDN.
Thanks for your help, will check a bit later today, it is in fact late
You're welcome, and let us know 🙂
You'll want to look at whether
useCdn
is true or false (set it) in creation config for the Sanity client reading your data to be served -- in the morning ;)
If you’re on nextjs add revalidate = 10
This will help you
Good day, usecdn set to true, is that the recommended setting?
I will try the revalidate option
revalidate is probably the best option
Thank you, works now, any reason why revalidate works but exportiing dynamic didnt?
not sure why
i am glad it worked for you
ok last question, whats the recommended usage
On the component itself? or within fetch?
on the page something like this
export const revalidate = 60;
ok
thanks again
this is currently what im working on btw
when its officially launched ill submit it into the "i-made-this" section

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?