CloudFront Update – Configurable Max and Default TTL
Amazon CloudFront makes it easy for you to distribute content to end users with low latency, high data transfer speeds, and no minimum usage commitments.
In order to make content available with low latency, CloudFront caches objects at each of its 53 (as of this writing) edge locations. Today we are making an update to CloudFront that will provide you with additional control over the caching behavior at each edge location. You already have the ability to set the minimum length of time (commonly known as the Minimum Time to Live, or Min TTL) that CloudFront should cache each object at the edge.
You can now configure the maximum value (Max TTL) as well as a default value (Default TTL) for the length of time that CloudFront should cache your objects. These settings apply on a per-behavior basis (recall that each of your CloudFront distributions can have one or more behaviors, each of which applies to a set of objects which match a regular expression). For example, you can set distinct TTL values for web pages (*.html) and PNG images (*.png). In many cases, it is easier to set these values at the behavior level rather than modifying the application to consistently generate the proper cache-control headers (you do, however, still have that option).
You can use these options in many interesting ways! For example, if you don’t set any cache control header on your origin, you can use the Default TTL to specify the cache duration for the edge locations. Or, you can completely override the cache-control header set by origin by setting all three of the values (Min, Max, and Default) to the same value.
This new feature is accessible from the AWS Management Console and the CloudFront API. Let’s say I have one distribution and three behaviors, like this:
I can select and then edit a behavior in order to exercise additional control over the TTL settings:
This feature is available now and you can start using it today at no additional charge. To learn more, read about Specifying How Long Objects Stay in a CloudFront Edge Cache in the CloudFront documentation.