Mobile app version of vmapp.org
Login or Join
Chiappetta492

: What's the best way to version CSS and JS URLs - part 3 this is a follow up question to this one What's the best way to version CSS and JS URLs - part 2 If I have my static files on

@Chiappetta492

Posted in: #AmazonCloudfront #CacheControl #StaticContent

this is a follow up question to this one What's the best way to version CSS and JS URLs - part 2

If I have my static files on Amazon cloudfront and have the file's URLs mentioned in my code. How will I be able to do versioning of my CSS files, so that the browser retrieves the latest version of the file when I update it on cloudfront.

Couple of things I do not want to do when I am doing this are


change the filename in cloudfront and change the urls everywhere in the code
and then restarting the application server


thanks

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gonzalez347

The browser will retrieve the latest version if the browser cached version has expired. It will not do an HTTP GET request until that happens. This is intended behavior, because you want the speed of not having the delay of testing if there's a newer version. This, and a way around it, has been explained in the questions you refer to.

Amazon CloudFront will fetch your file and keep it until it expires. That expiration time is 24 hours or the expiration time set in the header when it fetched your file, whichever is shorter. It will not come and fetch another version, it won't even test if there is a newer version. That is also intended behavior, so that the edge server can quickly accomodate the browser without having to wait for your site (or S3) to respond. That's why it's so fast.

You can work around this by using Object Invalidation. This is a feature of Amazon CloudFront that allows you to explicitly delete the file from the CloudFront edge servers. It takes a couple of minutes to complete, and there's a cost involved if you do it too frequently, but in the case of a script or CSS file that infrequently changes I don't see this as a problem. There's an API for it, and some tools (notably Cyberduck) allow you to do it for files that are stored in S3.

Combine the two, and I think you have the solution to your problem.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme