When you upload a new image while specifying its
public_id to be the same as an existing image, your Cloudinary account will be updated with the new image overriding the old one. However, if the original (older) image was already accessed, it might get cached in the CDN. Therefore if you access the exact same URL, you might be still getting a CDN cached version rather than the new updated one. When accessed, images are cached in the CDN for a period of up to a month. Sometimes, you'de would want your end-users to see the most recent image in an immediate manner.
We offer two ways to approach this obstacle. The first one is including the version component as part of the URL in order to bypass the CDN cached version and to force the delivery of the newest image. Cloudinary returns the updated value of the
version parameter as part of every upload API response. The
url parameter is also returned, and already includes the
version component (".../v1234567890/...") with the updated value. URLs retrieved through the media library also include the version component.
For more information:
Alternatively, when using the API, you can set the
invalidate parameter to
true at uploading time, in order to invalidate the image CDN cache. Note that it usually takes a couple of minutes, though might take up to an hour for the invalidation to fully propagate through the CDN. On the other hand, using the
version component, as described above, affects immediately. When uploading via the Media-Library the invalidation comes built-in in the request.
In addition, note that in default, when invalidation is requested (using the 'invalidate' parameter) Cloudinary invalidates URLs that do not include the version component. If you wish to invalidate "versioned" URLs, you should enable 'Invalidate versioned URLs' in your account's Upload settings page. Additional information can be found here.
Another option you might want to consider is to add a unique suffix to the public ID with every re-upload.