Amazon CloudFront wildcard cache invalidation

I have written several blog posts about the shortcomings of Amazon CloudFront.

One of the most important issues that I forgot to include was its limited cache invalidation capabilities.

Whilst you can invalidate an object with Amazon CloudFront you cannot use wildcards or regular expressions to invalidate objects.

For example if you had 10,000 products under http://www.site.com/womens/

With Amazon CloudFront you cannot invalidate using a wildcard

Nor can you invalidate the cache using a regular expression.

You have to invalidate URLs individually!

Just knowing the URLs you need to invalidate can be problematic. A work around is to process the Amazon CloudFront log files so you know which URLs have been requested and then call the Amazon CloudFront API for every URL to invalidate it. However, this is both time consuming, slow and error prone.

You can find more about the limitations

4 Responses to “Amazon CloudFront wildcard cache invalidation”

  1. Antonie Says:

    Great post, thank you.

    It would’ve been great to be able to use a wildcard to refresh files in a directory. I guess I’ll have to delete and recreate the distribution.

  2. Felipe Jaramillo F (@mrfelipe) Says:

    Antonie,
    I have ran into the same problem. But an added issue is the fact that a CNAME can only be used in a single distribution. This means you can’t have the old distribution serving content while you prepare the new one, or even a way to test this.

    I’ve found invalidating multiple URL’s a a huge pain that is just plain silly from CloudFront to have missed – in addition to not being able to set custom Headers.

  3. richardyeo Says:

    At long last…

    Amazon CloudFront’s invalidation feature, which allows you to remove an object from the CloudFront cache before it expires, now supports the * wildcard character. You can add a * wildcard character at the end of an invalidation path to remove all objects that match this path. In the past, when you wanted to invalidate multiple objects, you had to list every object path separately. Now, you can easily invalidate multiple objects using the * wildcard character.

    Using the * wildcard character in the invalidation path is useful for many use cases. For example, if you’re doing a new deployment, you can now just use /* to invalidate the entire distribution. Similarly, if you want to invalidate all objects for a specific end user, you can invalidate the content in a directory, for example, /enduser-x-data/*.

  4. Amazon CloudFront Wildcard Cache Delete | Contrid Says:

    […] Source: Amazon CloudFront wildcard cache invalidation | The diary of a CTO […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: