Issue with changes not showing up on production deployment without redeploying
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
1. Implement ISR (Incremental Static Regeneration) - Recommended for Next.js
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.
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.