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?
You should use the
cache-controlheader on this file (see in S3 "Metadata" tab) : set it topublic, 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)