Eli
Eli

Reputation: 38949

Cloudfront Seems to Serve Older Content than what's in S3

I have a Django app that's storing static files in s3 and using Cloudfront as the CDN to serve them. I recently updated a js file, and deployed it to the s3 bucket that serves content for the CDN. I verified that the content is correct in s3 and the upload times on it all make sense. Nevertheless, Cloudfront keeps serving an older version of the file (10 hours later). How do I deal with this?

Upvotes: 2

Views: 731

Answers (1)

Brandon Taylor
Brandon Taylor

Reputation: 34553

That's because the file being served by CloudFront is cached.

An easy way around this is to append a timestamp of the last-modified date to the url for the file, which will cause CloudFront to recache the file, or you can put in a version number into the name of the file itself. I take the version number approach.

If you don't change the name of the file or the URL, you'll get the cached version until the expires header date is met.

Upvotes: 2

Related Questions