Joint session with Vercel: How to build intelligent storefronts (May 15th)

CDN vs APICDN difference in Sanity and stale-while-revalidate caching

13 repliesLast updated: Nov 29, 2025

Noticing during a component refresh network traffic is fetching the same asset multiple times. I found this to use apicdn.sanity.io instead of api.sanity.io https://www.sanity.io/docs/api-cdn
Currently we are using this dependency
https://sanity.nuxtjs.org/getting-started/quick-start and setting
useCDN: true
but what it's using instead is cdn.sanity.io ? Is there a difference between cdn & apicdn??
I think also we need to adjust the time for "Stale while revalidate" to cache an asset for longer
AI Update

Based on your question, I can clarify the difference between these endpoints and help with your caching concerns.

CDN Endpoints Explained

There are indeed different CDN endpoints in Sanity, and they serve different purposes:

So when you're using the Nuxt Sanity module with useCDN: true, it's correctly using cdn.sanity.io for assets (images, files) and should be using apicdn.sanity.io for API queries. These are two different systems working together.

About the Duplicate Fetching Issue

If you're seeing the same asset fetched multiple times during component refreshes, this is likely a client-side issue rather than a CDN configuration problem. The Asset CDN caches indefinitely once an asset is processed, and uses content-addressable URLs (with SHA-1 hashes) that enable aggressive browser caching.

A few things to check:

Adjusting Stale-While-Revalidate

For the API CDN (apicdn.sanity.io), the cache behavior is controlled server-side by Sanity and uses stale-while-revalidate by default. You don't have direct control over the cache duration from the client side - this is managed by Sanity's infrastructure to balance freshness with performance.

If you need more control over caching behavior, you might want to implement your own caching layer (like using Nuxt's built-in caching features or a service worker) on top of Sanity's CDN.

The Asset CDN (cdn.sanity.io) caches assets indefinitely since they're content-addressed, so those shouldn't need adjustment - they're already maximally cached.

Show original thread
13 replies

Was this answer helpful?

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.

Related contributions