Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I would like to know if it's possible to clear CloudFront's cache,

The file concerned has changed on Amazon S3 but it's not being updated on CloudFront.

share|improve this question

migrated from superuser.com Feb 17 '11 at 11:29

This question came from our site for computer enthusiasts and power users.

3 Answers 3

up vote 4 down vote accepted

I found the answer using Python:

import boto
cf = boto.connect_cloudfront('aws_access_key_id', 'aws_secret_access_key')
cf.create_invalidation_request("distribution_id", ["/path1","/path2"])

Documentation:

share|improve this answer
    
I was wondering how to get the distribution_id. Found it through the python shell, with help of boto.s3.amazonaws.com/ref/cloudfront.html –  Rob W Oct 7 '12 at 10:18

In case you use Chrome, you can use this plugin.

Disclaimer: I'm the author.

share|improve this answer
    
Do you have an example of what a purge request looks like using the plugin? I'm confused on how that works. –  mheavers May 24 '12 at 16:10
    
What the complete url u wanna purge? if it is example.com/foo/bar.jpg you need to enter /foo/bar.jpg in the box –  sajal May 25 '12 at 10:18
    
Works perfectly. It took about 10 minutes to purge cache for one image, but that's Amazon's fault. Thanks a lot for this! –  sfarbota Nov 20 '13 at 21:47

Might be useful to know you can also do this right from the AWS Console.

Distribution Settings > Invalidations > Create Invalidation

Then just type in the paths to invalidate in the same format displayed there.

share|improve this answer
    
By far the easiest point-and-click method. Thanks! –  Arto Bendiken Mar 9 at 20:30

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.