Search code examples
amazon-s3amazon-web-servicescloudcdnamazon-cloudfront

How can I update files on Amazon's CDN (CloudFront)?


Is there any way to update files stored on Amazon CloudFront (Amazon's CDN service)? Seems like it won't take any update of a file we make (e.g. removing the file and storing the new one with the same file name as before). Do I have to explicitly trigger an update process to remove the files from the edge servers to get the new file contents published?

Thanks for your help


Solution

  • Amazon added an Invalidation Feature. This is API Reference.

    Sample Request from the API Reference:

    POST /2010-08-01/distribution/[distribution ID]/invalidation HTTP/1.0
    Host: cloudfront.amazonaws.com
    Authorization: [AWS authentication string]
    Content-Type: text/xml
    
    <InvalidationBatch>
       <Path>/image1.jpg</Path>
       <Path>/image2.jpg</Path>
       <Path>/videos/movie.flv</Path>
       <CallerReference>my-batch</CallerReference>
    </InvalidationBatch>