How to invalidate transformed image after source images are invalidated
I am compositing an image (result
) out of 3 other images (a.webp
, b.webp
and c.webp
) with the overlay (layer) transformation.
When I update one of the source images (a
, b
or c
) with the cld uploader upload
command I also send the invalidate
flag, but this only invalidates the cache of the source images, not of result
.
I think, I could use the explicit
method to force regenerating result
, but because I need the image in multiple resolutions, I want to avoid that. (I’m also giving a simple example. In my real world scenario, I do this compositing with hundreds of images).
Is there a way I can get this to work efficiently, or do I need to introduce version numbers here?
Answers
-
The process you have indicated is the recommended way to purge all the CDN copies of the individual overlay source images.
Overlay Image 1: https://res.cloudinary.com/epasos/image/upload/demo/images/sampleimageA.png
Overlay Image 2: https://res.cloudinary.com/epasos/image/upload/demo/images/SampleImageB.jpg
And in the case of the base image, when you re-upload another copy of the asset (i.e., using the parameters `invalidate=true, overwrite=true, public_id=sampleimage`) - this will purge the CDN copy of the derived versions of the base image.
Base Image : https://res.cloudinary.com/epasos/image/upload/demo/images/sampleimage.jpg
In this case, you could replace all the overlay images before you replace the base image so that all newer versions of the assets will be used. And after uploading the base image, you can perform the generation of the final derived asset version, for example:
Derived version of the Base Image: https://res.cloudinary.com/epasos/image/upload/l_demo:images:sampleimageA,g_south/l_demo:images:SampleImageB,c_scale,w_400/demo/images/sampleimage.jpg
As for the CDN invalidation, kindly see - https://support.cloudinary.com/hc/en-us/articles/360001208732-What-URL-conventions-are-invalidated
Hope this helps.
0 -
Just to make sure I understood completely: All dervied versions of a base image will be regenerated, when the base image itself is invalidated?
So in your case: if
sampleimage.jpg
is invalidated, then the derived version will be invalidated too. BUT ifsampleimageA
orsampleimageB
is updated, then the derived image will not be invalidated, correct?So I just need to make sure that I replace
sampleimageA
andsampleimageB
before updating (and invalidating)sampleimage.jpg
. Is that correct? :)0