Skip to content

How do I resolve the "TooManyInvalidationsInProgress" error for CloudFront invalidation requests?

2 minute read
0

I tried to invalidate files for my Amazon CloudFront distribution to remove content and received an "TooManyInvalidationsInProgress" error.

Short description

For individual files, you can make up to 3,000 invalidation requests for each distribution.

If you exceed this quota, then you might receive an error message that's similar to the following one:

"An error occurred (TooManyInvalidationsInProgress) when calling the CreateInvalidation operation: Processing your request will cause you to exceed the maximum number of in-progress invalidations."

To resolve this issue, use versioned file names or wildcards, control cache file time, or implement a retry mechanism with exponential backoff.

Resolution

Use versioned file names

If you frequently update your files from your distribution, then it's a best practice to use versioned file names. Versioned files let you better control over-cached files and are less expensive than file invalidation. For more information, see Choose between invalidating files and using versioned file names.

Use wildcards

You can use wildcards in the invalidation path with a maximum of 15 invalidation paths in progress at the same time with no file quotas. You must put the wildcard (*) at the end of the invalidation path, such as /images/image.jpg*.

Control the amount of time that CloudFront caches files

You can change the configuration on the origin or distribution to specify the amount of time that CloudFront caches objects. It's a best practice to use a cache policy and origin request policy to control the cache key and origin requests.

If you don't need to cache your content, then use the CachingDisabled policy to turn off caching. For more information, see How do I change my configurations so that CloudFront doesn't cache certain files?

Implement retry mechanism with exponential backoff

It's a best practice to build retry logic into your applications to retry requests that return an error. All AWS SDKs have a built-in retry mechanism with an algorithm that uses exponential backoff. The algorithm implements increasingly longer wait times between retries for consecutive error responses. Many exponential backoff algorithms use jitter to prevent successive collisions. For more information, see Retry behavior.

Relation information

What you need to know when invalidating files

Quotas on invalidations

CreateInvalidation

AWS OFFICIALUpdated a year ago