1

I started to use AWS S3 to provide a fast way to my users download the installation files of my Win32 apps. Each install file has about 60MB and the download it's working very fast.

However when i upload a new version of the app, S3 keeps serving the old file instead ! I just rename the old file and upload the new version with the same name of the old. After i upload, when i try to download, the old version is downloaded instead.

I searched for some solutions and here is what i tried :

  • Edited all TTL values on cloudfrond to 0
  • Edited the metadata 'Cache-control' with the value 'max-age=0' for each file on the bucket

None of these fixed the issue, AWS keeps serving the old file instead of the new !

Often i will upload new versions, so i need that when the users try to download, S3 never use cache at all.

Please help.

delphirules
  • 6,443
  • 17
  • 59
  • 108
  • S3 doesn't cache, CloudFront does and user's browsers do. – jordanm Jul 02 '20 at 18:57
  • On devtools I'm setting my browser to use no cache. So if it's cloudfront the guilty guy, what should i do to really fix the issue, please ? – delphirules Jul 02 '20 at 19:01
  • Purge all of the cloudfront cache after setting the proper cache-control metadata. Long term, design your system to use versioned assets – jordanm Jul 02 '20 at 19:33

1 Answers1

1

I think this behavior might be because S3 uses an eventually consistent model, meaning that updates and deletes will propagate eventually but it is not guaranteed that this happens immediately, or even within a specific amount of time. (see here for the specifics of their consistency approach). Specifically, they say "Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all Regions" and I think the case you're describing would be an overwrite PUT. There appears to be a good answer on a similar issue here: How long does it take for AWS S3 to save and load an item? which touches on the consistency issue and how to get around it, hopefully that's helpful

hjobrien
  • 141
  • 1
  • 10
  • So as far as i understood, i can't use S3 if i need the new files are served as soon as they are uploaded ? – delphirules Jul 02 '20 at 19:22
  • 1
    The other SO link I posted offers some alternatives, but I think one you might want to explore is switching to just PUTS without overwriting old data (e.g. non-overwrite PUTS). This might/probably would mean you'd have to change the downloading client, but it'd let you avoid the consistency issue – hjobrien Jul 02 '20 at 19:35
  • I think the best approach will be when upload a new version, include the version in the file name, so each new version will have a different filename. It's extra work, but... – delphirules Jul 03 '20 at 11:45