amazon-web-servicescachingamazon-s3cloudinaryfastly

How can I stagger purging multiple cascading CDN's to assure a complete purge?


I use an Amazon S3 bucket, a cloudinary cache, and a fastly cache. In conjunction, they deliver images of any shape, size, or other transformation you ask for, and very fast. However, they propagate purge requests at different rates.

Here is the cascading arrangement:

I'd like to completely remove an image and all transformed versions (derivatives) of that image from all of my services. Cloudinary takes an hour to propagate the DELETE request to all of its servers.

I see that it is best to delete first in S3, then Cloudinary, and finally to purge fastly. How best does one delay a purge call for an hour though? What is the best practice, programmatically speaking, in this situation?


Solution

  • As part of its solution, Cloudinary provides CDN services via Akamai (integration to other CDNs is also available).

    Images are cached on the CDN after initial delivery and until a purge is requested. The propagation to all CDN nodes takes time and may last up to 1 hour, however usually only takes several minutes.

    Coordinating between two CDN layers is a quite complex task, therefore the best practice is to avoid using your own CDN in front of Cloudinary's, especially if invalidations are commonly required.