How to invalidate CDN cache for deleted image assets in Sanity?

21 replies
Last updated: Oct 14, 2024
Hi there!
My team deleted some image assets from our Sanity CMS. However, it appears those images are still available from the CDN. When reviewing the
CDN’s caching protocol it looks like assets are cached indefinitely. It is important we remove this asset we removed due to some copywright issues. How can we invalidate the cache for these images so that the Sanity CDN will remove them from cache?
Thanks a bunch!
AI Update

I understand your concern about copyright issues - this is definitely something that needs immediate attention.

Unfortunately, based on Sanity's Asset CDN documentation, assets are cached indefinitely once processed, and cache invalidation only occurs when an entire dataset or project is deleted. This is by design because Sanity uses content-addressable URLs (with SHA-1 hashes) that change when content changes, so there's typically no need for manual cache invalidation.

However, for urgent situations like copyright violations, you need to contact Sanity support directly. Here's what I recommend:

Immediate Steps:

  1. Contact Sanity Support - Reach out to support@sanity.io or use the support chat in your Sanity dashboard. Explain the copyright situation and provide:

    • The specific asset URLs that need to be removed
    • The asset IDs from your dataset
    • Details about the copyright issue
  2. Delete the assets from your dataset - If you haven't already, make sure to delete them from Sanity Studio or via the API to prevent future references

  3. For DMCA takedowns - If this is a formal DMCA situation, Sanity will have a process for handling these legal requests. They'll need proper documentation of the copyright claim.

Why you can't do this yourself:

The Asset CDN is managed infrastructure, and regular users don't have access to purge individual assets from the cache. This is different from the API CDN where you might have more control. Since assets are distributed across Google's global CDN infrastructure, only Sanity's operations team can force a cache purge.

Bottom line: Contact Sanity support immediately (support@sanity.io or through your dashboard chat) with the asset details and explain the copyright urgency. They should be able to help expedite the removal from the CDN given the legal nature of the issue.

Show original thread
21 replies
Are you using the 'media plugin' by chance? A thought -- maybe you've removed the reference to the image from where it was used, but the 'image' itself might still be in your dataset and that might be keeping it in the cache?
The media plugin gives you a view into all the media assets whether they are referenced or not. That might be enough to give the cdn a kick?
Great idea to check on that! My team did delete the images from the Media plugin/gallery
đź‘‹ GCP services our asset CDN, so you would try using the method described here to invalidate it yourself.
user M
I doubt end users can invalidate cache from GCP just like that. It would entail having authorization to do so, right?
Yeah shouldn’t deleting an image delete the image from the cache and invalidate it. I would assume that be the way it works. Has anyone else ran into this issue before?
Also
user M
, isn’t this the Sanity CDN? How would I have the ability to invalidate Sanity’s cache?
If it is copyright related concerns in any cache you can probably go that route and google would have to 'respect' that some how. But if you're the one who violated the 'copyright' by putting it in, the 'process' might not allow for that... I'd think you'd have to then have the original rights holder of the image make the request which would just be way more complicated than it is worth.
Hey Chris, I don’t think I am following. Are you saying I have to reach out to Google in order to invalidate Sanity’s cache?
My team really needs this image cleared from Sanity’s cache as the images are under copywright.
user F
Our team is looking into this, and we’ll follow up once we hear back.
Thank you!!
I’m now getting a 404 on both of the image URLs you requested. It may take a bit more time to propagate, but please confirm when you get the chance.
Thank you Geoff! I am seeing the 404 on one of the images. But as you said it might take more time to propgate. I will confirm when I see the other image propagate
The backend team has confirmed this purge process is completed from our side.
Have you cleared your browser’s cache?
Is that perhaps in your browser’s cache?
Yes, and used an incognito browser
Oh shoot I need more coffee
It is showing 404 now
Thanks team!
Hi I am experiencing the same issue. I deleted a PDF via Sanity Studio but the link is still active.

user A
user M
user F
did Sanity support team have to intervene in order to invalidate the cache? Or did you just have to wait for the changes to propagate through the CDN?

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?