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 Browser caching Browsers cache objects for the value of the |
CloudFront caching
CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the
Browser caching Browsers cache objects for the value of the |
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-maxage directives to objects |
CloudFront caching
CloudFront caches objects for the lesser of the value of the Browser caching Browsers cache objects for the value of the |
CloudFront caching
CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the
Browser caching Browsers cache objects for the value of the |
The origin adds an Expires header to objects |
CloudFront caching
CloudFront caches objects until the date in the Browser caching Browsers cache objects until the date in the |
CloudFront caching
CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL and the
Browser caching Browsers cache objects until the date and time in the |
Origin adds Cache-Control: no-cache , no-store , and/or private directives to objects |
CloudFront and browsers respect the headers.
For an exception to how CloudFront handles the |
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