0

My CloudFront distribution is backed by an S3 bucket.

I have a file that is updated very frequently (every 10 minutes) which contains real-time data and is about 100k in size. This file is used by our desktop software and has a constant name/url.

I currently set the Expires header to 9 minutes to ensure all users always get the current file. If I wanted to use versioning, I don't know of a way to force a redirect in S3 like:

www.example.com/datafile.gz -> www.example.com/datafile-2019-01-07-23-50.gz

Is there a way to do this so that I could just upload the new file with a dated name and change the redirect?

Trygve
  • 1,317
  • 10
  • 27

1 Answers1

0

You should use the cache-control header on this file (see in S3 "Metadata" tab) : set it to public, s-maxage=9, max-age=9. The file will be cached on the CDN and on the user browser for 9 minutes.

A more reactive directive could be public, s-maxage=1, max-age=9 (CDN will cache the file for 1 minute and browser for 9)

JayMore
  • 642
  • 6
  • 20
  • Doesn't max-age=9 make it cache for 9 minutes AFTER it is requested? If it is not requested until 5 minutes after it is created, then it will really cache for 14 minutes since its creation time. – Trygve Jan 08 '19 at 16:28