Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

up vote 6 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"])


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
Is a distribution id safe to hard-code in public source code or is it "sensitive" information (like the aws_access_key_id and aws_secret_access_key) that should be provided say, as an environment variable? – mdwhatcott May 12 at 15:32

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 '14 at 20:30

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

Your Answer


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.