Question

I have setup static files (css, images and js) files on a cloudfront distribution and am using the cloudfront URLs of the files to refer to them in the JSP files. I have setup cache-control value to a max of one month.

Suppose if I modify the css/js files before cache expires and update the files in the cloudfront distribution after invalidating the original object.

What are the ways in which I can make sure that the browser fetches the updated file ?

Was it helpful?

Solution

Amazon recommends a technique they call "versioning" which basically means change the object's filename when you change the object.

The CloudFront developer manual ( http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?ReplacingObjects.html ) describes it as follows:

We recommend that you use the common technique of versioning to give yourself better control of your content. Versioning means that you assign each object in the origin server a version number. For example, instead of calling the file image.jpg, you call it image_1.jpg. Then when you want to start serving a new version of the file, you name that new file image_2.jpg, and you update your links to point to image_2.jpg. With versioning, you do not have to wait for an object to expire before you can serve a new version of it.

Even though you might be versioning your objects, we still recommend you set an expiration date that you feel is appropriate for your objects. For more information see Object Expiration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top