Reputation: 2412
I was following this post to optimize Cloudfront costs but my architecture is a little bit different
I have a Cloudfront distribution in front of a lambda function (api gateway) that makes en http call to a image hosted in another server then resizes it to a given size and returns it. then Cloudfront caches it for 1 year. I´m not storing the resized images in S3 at all. I set the expiration to 1 year.
what are some good options to reduce Cloudfront costs? is the 1 year expiration a good practice?
Amazon CloudFront SA-Requests-Tier2-HTTPS 5,561,818.000 Requests: $12.24
bandwith: $0.110 per GB - first 10 TB / month data transfer out 355.339 GB: $39.09
Upvotes: 1
Views: 713
Reputation: 269350
Amazon CloudFront will not cache your object for one year.
CloudFront points of presence have large, but not infinite, storage. When the cache space fills up, less-frequently accessed files are removed. If your image is infrequently accessed, then it will not be stored in CloudFront for a long period.
Instead, CloudFront will call the back-end again, so your API Gateway will receive a request for a resized object again.
Upvotes: 2