I'm putting assets to S3 with expiry headers, which successfully get passed through to CloudFront distributions. However, requests after the expiry don't result in CloudFront requesting a fresh file from the origin server.
I am also finding that query string version tokens don't force a fresh asset, and I don't want to use full, file name versioning.
All of this may be down to my poor knowledge of cache-control headers, but I am starting to wonder if I am missing something critical about how CloudFront is supposed to work. The CloudFront responses are showing headers like the following.
Cache-Control: max-age=120
Expires: Tue, 07 Apr 2009 12:13:26 GMT
Right click your distribution. Select "Get Cloudfront invalidation list" Then select "Create" to create a new invalidation list. Select the files to invalidate, and click "Invalidate." Wait 5-15 minutes.
By default, each file automatically expires after 24 hours, but you can change the default behavior in two ways: To change the cache duration for all files that match the same path pattern, you can change the CloudFront settings for Minimum TTL, Maximum TTL, and Default TTL for a cache behavior.
Short description. By default, CloudFront caches a response from Amazon S3 for 24 hours (Default TTL of 86,400 seconds). If your request lands at an edge location that served the Amazon S3 response within 24 hours, then CloudFront uses the cached response. This happens even if you updated the content in Amazon S3.
Minimum TTL Specify the minimum amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The default value for Minimum TTL is 0 seconds.
Time passes and things change. As Tim had noted, the lowest cache time was 24hrs but in April 2010 Amazon announced that they will recognize and follow directives for caching down to an hour.
Announcement here: http://developer.amazonwebservices.com/connect/ann.jspa?annID=655
Looks like Amazon ignores expiry times less than 24 hours. http://developer.amazonwebservices.com/connect/thread.jspa?messageID=107699𚒳
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With