I am building a ReactJS app using create-react-app build, and deploying to Amazon S3 and CloudFront. Deploying is easy enough; when I create a new version, I can sync the build directory to S3, hit reload, and everything works well. The index.html contains references to the latest build via unique hash keys, so I always get the latest files.
But what about active users that are using the old version(s) of index.html
? Their browsers will reference "chunks" that no longer exist. How should I update to my latest build without disturbing these users?
A blunt solution might be to keep the files from the older builds, but then the user would not be automatically updated to the new version. And cleanup of the old files would be messy.
In my CloudFront setup, when an active user requests a missing chunk, the browser will be directed to index.html
for the 404/403 errors. Perhaps the upgrades are already managed automatically, forcing a reload of index.html (and therefore references to the new files)?