When you overwrite an existing image with a new file that uses the same public_id
value your Cloudinary account will be updated with the new image and new requests we receive for that resource will be served the new image right away.
If the resource was already in use in your application or website, when accessing existing URLs for that resource you may still see a CDN cached version of the previous image instead of the new updated image.
There are two ways to handle this.
Firstly, you can include the version component as part of the URL. The version number of the asset is included in theversion
property that's included in our Upload API and Admin API responses, and it's also included in the path to the image returned in the url
or secure_url
parameters of those APIs, and in the URLs retrieved through our media library
If you keep your database up to date with the version number for each resource and use it in the URLs that your application creates, you'll always get the newest version of the image: https://cloudinary.com/documentation/upload_images#asset_versions
Alternatively, when using the API, you can set the invalidate
parameter to true
in your call to the upload API to request that we invalidate the CDN cache for the image. When using our Media Library UI, invalidation is requested automatically. Note that it typically takes a few seconds to take effect, but invalidation can take up to an hour to fully propagate through our CDNs.
When invalidation is requested Cloudinary sends invalidation requests for the same URL format created by our SDKs by default, which does not include the version component, but includes a 'v1' placeholder instead of the version when the image is in a subfolder of your account.
If you're using a different method to generate your URLs, you may need to account for this in your account settings or ask us to change the invalidation behavior for your account
If you wish to invalidate "versioned" URLs instead of this default, you should enable the 'Invalidate versioned URLs' in your account's Upload settings page.
For more information about CDN invalidations, please see the upload API documentation
https://cloudinary.com/documentation/additional_upload_api_options#invalidating_cached_media_assets_on_the_cdn
Comments
33 comments
Thanks
Shirly said: You can add `invalidate:true` on upload and it will invalidate the new version. For example in NodeJS:
Why does this not work for Unsigned Uploads? This thing is driving me nuts! It's seriously changing my mind about using Cloudinary in my projects.
Hi Malcolm,
When using unsigned upload we don't allow updating/deleting existing images. It for security reasons. because unsigned upload can upload is for anyone to upload assets to your account but we don't want to let them delete or update your existing assets.
Hope it makes sense,
Shirly
Please sign in to leave a comment.