Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

After checking on Google PageSpeed Insights, I have optimised the images on several websites using jpegoptim and optipng.

Obviously a lot of the images are now smaller and they have new timestamps, but they have not been updated through the Amazon CloudFront CDN.

The expire headers in .htaccess have been set for one year.

There are many hundreds of images that have been optimised, so manually invalidating them is not that feasible.

What is the best way to do this?

share|improve this question

1 Answer 1

If you have the names of the files you can paste those into CloudFront's invalidation web interface.

On Linux and Mac, you can get all the filenames easily by selecting the files in the file browser, copying them (Ctrl+C or Cmd+C) then pasting into a text editor. Then use find/replace to get them in the correct format for AWS. That doesn't work on Windows though.

Alternatively, you could write a super quick script in PHP to get the file names and output that for copy-pasting into AWS.

The other method would be to do it programmatically. Download the SDK and follow the tutorials and docs on the site for your chosen language.

share|improve this answer
    
I have decided to make a new distribution, as so many files need to be invalidated, it would be cheaper this way. Instead of going through the hassle of changing DNS CNAME records, is it possible to recreate the origin instead? –  paradroid Feb 21 at 3:39
    
I've asked here - webmasters.stackexchange.com/q/58530/2029 –  paradroid Feb 21 at 3:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.