CloudFront Invalidation

I've recently been playing with CloudFront's new Invalidation feature and had some time to add it to boto. There's still a few things left to add, but you can perform a general invalidation now using boto:

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

This will automatically invalidate any URLs you pass in. You can also use the "cfadmin" command line tool to invalidate paths without running a python shell:

% cfadmin invalidate\ /path1 /path2
You can use either the origin or the distribution id as the first parameter to the "invalidate" function.
Note that Amazon limits how many invalidations you can have running at any given time, and they also only let you invalidate so many files with one request. This should be used only to remove things on a non-regular basis (i.e. mistakes or Copyright Infringement notices). You can still use the cachecontrol headers to determine how long files are cached in cloudfront.


findchris said…
In your experience, how long does the invalidation take? I've had an invalidation request 'InProgess' for 10 minutes already and I want to know what to expect.

findchris said…
FWIW, I'm seeing about 10-15 minutes for each request to complete.
Chris Moyer said…
I see anywhere from 5 to 30 minutes before invalidations take effect. It all depends on how many you perform. I often see larger delays when I perform several invalidation requests all at once.
kirti said…
CloudFront is becoming fast service used by more of the mainstream market and while CloudFront won't displace any of the big CDNs anytime soon, Amazon's service is quickly becoming more competitive.I am really enjoying it...I am using Bucket to invalidate my stuff on S3 edge location...its really easy...