Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Pretty bizarre.

In my webapp, I have a link to a spreadsheet that's stored in S3. I have downladed that file before. Now, I updated that file in s3.

When I try to download it again from the same link, I still get the previous version.

If I clear the cache, it will download the newer version...

share|improve this question
    
It does cache the file, though the cache is deleted very often, it is more likely your file's already deleted. –  MilanorTSW Oct 7 '11 at 16:53
    
For some reason, it is not going away after like 10 hours. Maybe because I downloaded that link 10 or 15 times in a day, Chrome thinks it is useful to cache it for extended period. I cleared the cache, it is working now. I guess I should "release note" this. –  thinkanotherone Oct 7 '11 at 17:01
    
What's the HTTP expiry and cache settings for the page in your web app from which you are linking to the file on S3? –  Ƭᴇcʜιᴇ007 Oct 7 '11 at 20:45

3 Answers 3

up vote 2 down vote accepted

You have two choices to work around this:

  1. You can tell Amazon how to set the Cache-Control header when your URL is retrieved. The same way you specify the Content-Type header, you can control other headers as well. You can turn the caching down to a much shorter time interval.

  2. You can control the caching of the web page that links to the file on S3 and modify the link to the S3 file so that its contents won't be used from cache when the file changes. Basically, you can just put a ?version=1 on the end of the URL. If you change that to ?version=2 (and so on), the browser won't use the cached version of the file because the URL won't precisely match.

This second method allows you to use aggressive caching on the S3 file and avoid wasted transfers. But it requires you to modify every web page that links to the file every time you change the contents of the file.

See Lower your Amazon S3 Bill for more on both techniques, though you're trying to get the opposite effect.

share|improve this answer

Yes it does. I am having the same issue even if i am not using S3 as storage. I have a Symfony2 app that serves the contents of a local file for download. The url is always the same because i am getting the contents of the file in PHP and send them to the browser. If i modify the content of the local file, Firefox and IE will receive the latest file version BUT chrome won't. I tried to set cache control headers but it's useless, Chrome just ignores them.

Some idea of the headers i am using:

$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);

If i add a random version number to the url (?version=randomIntByTime) Chrome will finally save the latest version of the file. It is frustrating to write extra code for Chrome.

share|improve this answer

No, but it is possible that there is another caching device between you and S3. Like Microsoft's ISA server, which has caching of web traffic and I've seen it do this kind of thing many times.

share|improve this answer
    
I am connecting from my home DSL connection. –  thinkanotherone Oct 7 '11 at 16:57
    
Well, I'm guessing you don't have an ISA server then! But you could easily test the theory that Chrome is caching it by using IE or Firefox for the same request. Or just clearing Chrome's cache. –  Coding Gorilla Oct 7 '11 at 17:05
    
I did. But I guess I was hoping for someone who knows the inner working. –  thinkanotherone Oct 7 '11 at 17:19

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.