CloudFront Edge Cache Settings


Caching is ‘fun’ if you don’t set it up correctly. A useful cheat sheet of CloudFront edge cache TTL settings that I found in AWS documents site.

Origin Configuration Minimum TTL = 0 Seconds Minimum TTL > 0 Seconds
The origin adds a Cache-Control max-age directive to objects CloudFront caching

CloudFront caches objects for the lesser of the value of the Cache-Control max-age directive or the value of the CloudFront maximum TTL.

Browser caching

Browsers cache objects for the value of the Cache-Control max-age directive.

CloudFront caching

CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the Cache-Control max-age directive:

  • Minimum TTL < max-age < maximum TTLCloudFront caches objects for the value of the Cache-Control max-age directive.
  • max-age < minimum TTLCloudFront caches objects for the value of the CloudFront minimum TTL.
  • max-age > maximum TTLCloudFront caches objects for the value of the CloudFront maximum TTL.

Browser caching

Browsers cache objects for the value of the Cache-Control max-age directive.

The origin does not add a Cache-Control max-age directive to objects CloudFront caching

CloudFront caches objects for the value of the CloudFront default TTL.

Browser caching

Depends on the browser.

CloudFront caching

CloudFront caches objects for the greater of the value of the CloudFront minimum TTL or default TTL.

Browser caching

Depends on the browser.

The origin adds Cache-Control max-age and Cache-Control s-maxagedirectives to objects CloudFront caching

CloudFront caches objects for the lesser of the value of the Cache-Control s-maxage directive or the value of the CloudFront maximum TTL.

Browser caching

Browsers cache objects for the value of the Cache-Control max-age directive.

CloudFront caching

CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the Cache-Control s-maxage directive:

  • Minimum TTL < s-maxage < maximum TTLCloudFront caches objects for the value of the Cache-Control s-maxage directive.
  • s-maxage < minimum TTLCloudFront caches objects for the value of the CloudFront minimum TTL.
  • s-maxage > maximum TTLCloudFront caches objects for the value of the CloudFront maximum TTL.

Browser caching

Browsers cache objects for the value of the Cache-Control max-age directive.

The origin adds an Expires header to objects CloudFront caching

CloudFront caches objects until the date in the Expires header or for the value of the CloudFront maximum TTL, whichever is sooner.

Browser caching

Browsers cache objects until the date in the Expires header.

CloudFront caching

CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the Expires header:

  • Minimum TTL < Expires < maximum TTLCloudFront caches objects until the date and time in the Expires header.
  • Expires < minimum TTLCloudFront caches objects for the value of the CloudFront minimum TTL.
  • Expires > maximum TTLCloudFront caches objects for the value of the CloudFront maximum TTL.

Browser caching

Browsers cache objects until the date and time in the Expires header.

Origin adds Cache-Control: no-cacheno-store, and/or privatedirectives to objects CloudFront and browsers respect the headers.

For an exception to how CloudFront handles the Cache-Control: no-cache header, see Simultaneous Requests for the Same Object (Traffic Spikes).

CloudFront caching

CloudFront caches objects for the value of the CloudFront minimum TTL.

Browser caching

Browsers respect the headers.

 

Reference:
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html
https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching

 

Advertisement

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 )

Connecting to %s