Force refresh / invalidate CDN cache of a fetched image
Hello,
I would like to force the refresh of a fetched image.
For this purpose I make an API call via 'delete_resources' method (PHP Library)
$this->api->delete_resources([$publicId], ['type' => 'fetch', 'invalidate' => true]);
My image is deleted from the Media Library but is still available in CDN cache.
I'm aware that the default cache period for fetched resources is 7 days but with an invalidation call shouldn't it be deleted/refreshed in few minutes?
I'm not looking for a periodic refresh (7 days is ok) but I'd like to know if a quick manual force refresh is possible.
-
Hi Julien,
By default, the bulk delete method of our Admin API delete_resources() does not allow invalidations.
If you need to delete and invalidate a single resource, you can and should use the destroy() method of the Upload API, while including the 'invalidate' => true parameter in your request, the same way you did in your example when trying to invalidate via the delete_resources() method.
However, as you've already deleted the resource, you won't be able to delete it again with destroy.
Therefore, please share with me the relevant URL for the fetched image and I will invalidate it for you manually.Best,
Raz0 -
Hi Raz,
With Upload Api everything is now working as expected.
No need to worry about previous deleted images, it was only for testing purpose.
Thank you very much for your answer, great support :)
Julien0 -
Hi Raz,
I am fetching as url (https://res.cloudinary.com/<cloud_name>/image/fetch/d_no_image_560_sesesk.png,f_webp,q_auto:good/f_webp/https://asia.olympus-imaging.com/content/000107506.jpg) and have a look at destroy() method but it is asking for signature, how do I get the signature in my case or is there any other way to refresh the fetched image?
Thank you !0 -
Hey there,
Sorry, we have had some recent issues with our forum system and unfortunately, we were unaware of your last question. I want to make sure you've gotten the information you needed to progress in your project.
By far the easiest method to generate a signature is utilizing one of our SDKs, Cloudinary provides comprehensive API client-libraries in order to save you the hassle of generating the HTTP request and the signature by yourself.If you still require doing that on your own, you might want to check out how it's done on our client libraries. Below are some references to start from:
api_sign_request(params_to_sign, api_secret)
\Cloudinary::api_sign_request($params_to_sign, $api_secret)
api_sign_request = function(params_to_sign, api_secret)
apiSignRequest(Map<String, Object> paramsToSign, String apiSecret)
api_sign_request(params_to_sign, api_secret)
SignParameters(IDictionary<string, object> parameters)
cld utils api_sign_request $params_to_sign $api_secret
Few more tips:
- The string to sign must consist of a valid Timestamp (UNIX format), your account's
api_secret
and any additional upload parameter in use except:file
,cloud_name
,resource_type
and yourapi_key
. - String to sign must contain all required parameters sorted alphabetically, where the parameter names are separated from their values with an
=
and the parameter/value pairs are joined together with an&
, and end with theapi_secret
. -
api_secret
should never be revealed to anyone who is not authorized, therefore should never be used on the client-side or inside your native application. - Mobile native applications must either use an unsigned-upload or have a server to process the signature on.
- A signature is only valid for 1 hour since the timestamp it's based on.
- Sanity check - Signing the following string:
"public_id=sample_image×tamp=1315060510abcd"
where `abcd` is theapi_secret
, should result in the following signature:
"b4ad47fb4e25c7bf5f92a20089f9db59bc302313" - More information is available here:
https://cloudinary.com/documentation/upload_images#generating_authentication_signatures
0 - The string to sign must consist of a valid Timestamp (UNIX format), your account's
Post is closed for comments.
Comments
4 comments