I want to specify the amount of time that my Amazon CloudFront distribution caches objects, so I added Cache-Control or Expires headers on the origin. However, CloudFront doesn't cache objects for the amount of time I specified, or CloudFront doesn't cache at all. Why is this happening?

You can use caching headers (Cache-Control or Expires) on the origin to set how long CloudFront or web browsers should cache objects. Additionally, you can customize the cache duration (Minimum TTL, Default TTL, and Maximum TTL) for all objects with the same path pattern.

Be sure that all the settings for cache duration do not conflict with each other. For more information, see Specifying the Amount of Time that CloudFront Caches Objects for Web Distributions.

Avoid the following examples of inconsistent duration settings:

  • If you set the Maximum TTL to 5 minutes (300 seconds) and the Cache-Control max-age header to 1 hour (3600 seconds), then CloudFront caches the object for 5 minutes instead of 1 hour.
  • If you set the Cache-Control max-age header to 3 hours and the Expires header to 1 month, then CloudFront caches the object for 3 hours instead of 1 month.
  • If you set the Default, Minimum, and Maximum TTL to 0 seconds, then CloudFront acts as a proxy and doesn't cache the objects.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-04-09