Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Rails-generated JS file that I want to distribute via CloudFront (using my Rails app on EC2 as the origin server). Does anyone know which headers I should use in the response for my JS file to ensure that the end user's browser does not cache the JS file?

I know CloudFront does not respect any expires headers that are less than 1 hour... but the docs say those headers are still passed on to the client: http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/

Am I safe using the following?

Cache-Control: no-cache
Pragma: no-cache
share|improve this question
    
It seems like those headers make it so that CloudFront doesn't even cache the content... every request seems to be hitting my origin server. –  Aaron Gibralter May 29 '11 at 2:39
    
Why are you using CloudFront for a file that shouldn't be cached? –  sam Jun 1 '11 at 20:40

2 Answers 2

up vote 1 down vote accepted

Hmm so it turns out I don't really want to be doing that at all. CloudFront respects no-cache headers so this will, in fact, not cache the JS file on CloudFront for an hour. It doesn't really make sense to use CloudFront for this... more information can be found on my AWS Forums post.

share|improve this answer

Apparently CF no longer respects no-cache header any more. I tried a few combinations of Cache-Control, Pragma, and Expires headers but CF always returns X-Cache:Hit from cloudfront after the first access. It does however pass these headers on to the client as-is.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.