I have static files located on Amazon S3, and am continually having issues with Amazon caching them. When I update/overwrite the static file, I'd love for it to automatically show the newest version rather than waiting...
Any ideas?
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.
On your custom origin web server application, add Cache-Control no-cache, no-store, or private directives to the objects that you don't want CloudFront to cache. Or, add Expires directives to the objects that you don't want CloudFront to cache.
you can set Cache-Control as Metadata on S3 using Bucket Explorer, or S3 Broswer. bucketexplorer.com is not available anymore. See docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/… to disable the cache of an object.
I'm using the Javascript SDK and was able to resolve the problem by setting GetObject()
's ResponseCacheControl
parameter to "no-cache"
.
Add to the parameters of putObject() or upload() the following:
CacheControl: "no-cache"
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