I have a static website hosted on S3 with Cloudfront and I can't get TTL to work

106 views Asked by At

I've set the TTL max, min and default all to 0 (on the "Default Cache Behavior Settings" page), thinking this would mean that when I upload a new file called events.html to S3 it would replace the old events.html page, but I'm still seeing the cached version after a few hours.

I am just trying to update the content on some of my webpages.

1

There are 1 answers

0
ExploringApple On

If you want to invalidate your cache with new update in s3, you need to do it explicitly with putobject event. You can call the lambda to invalidate CF cache.

Here is example: https://blog.miguelangelnieto.net/posts/Automatic_Cloudfront_invalidation_with_Amazon_Lambda.html

Be aware that with above approach, if you refresh cache more than 1000 files in a month you have to pay extra invalidation fees. Refer CF pricing.

Also with TTL, you can do it but it will happen after the TTL value is elapsed and you have to clear the browser cache to view it.