Regenerating Thumbnails invalidates CDN caches one image at a time
-
I just used regenerate thumbnails and logged into AWS Cloudfront only to notice a $422 invalidation charge. I did some investigating and noticed that every time Regenerate Thumbnails deletes an image W3 Totlal cache was sending an invalidation to AWS Cloudfront. In my case this was 82,532 invalidations.
Below is an example invalidation sent to Cloudfront for deleting 1 Image resulting in 6 URL invalidation requests.
/wp-content/uploads/148588-dark-heather-150×150.png
/wp-content/uploads/148588-dark-heather-300×300.png
/wp-content/uploads/148588-dark-heather-100×100.png
/wp-content/uploads/148588-dark-heather-240×300.png
/wp-content/uploads/148588-dark-heather-50×50.png
/wp-content/uploads/148588-dark-heather-320×400.pngPlease warn your users that they can incur substantial CDN charges for invalidations. W3 Total Cache has an option which should be checked in order to NOT send an invalidation when deleting a file.
(x) Only purge CDN manually
I could send 1 invalidation request such as /* to remove all files from Cloudfront. This would have wiped out all 82,532 files and I would not have been charged 1 cent to remove them all. When sending each url invalidation individually is where the charges escalate. Perhaps you could even delete files using wildcard * like /wp-content/uploads/148588-dark-heather* to remove all the files which would have resulted in 6x less invalidations since I had 6 different media sizes.
- The topic ‘Regenerating Thumbnails invalidates CDN caches one image at a time’ is closed to new replies.