Essentially, if I upload new files to S3 (via drag-and-drop), my website should be up to date on visit, not cached as the previous version. Right now the behavior is possibly inconsistent. iOS generally doesn't update on refresh, while Chrome and Firefox might update properly on refresh. The ideal scenario is that iOS, Android, Chrome, Safari, Firefox, Edge should all update on the next visit or next refresh (if website is already open).
I have been reading about cache busting a while now, but I haven't encountered an easily understandable solution to display the updated S3 static website for React.
As I understood it, yarn build
already automatically generates new file names:
{
"main.js": "static/js/main.72dbb977.js",
"main.js.map": "static/js/main.72dbb977.js.map",
"static/js/0.d70486e8.chunk.js": "static/js/0.d70486e8.chunk.js",
"static/js/0.d70486e8.chunk.js.map": "static/js/0.d70486e8.chunk.js.map"
}
Because the names are new and different, the new version should be loaded and there should be no issue with cache. But this is not the case.
I saw a few solution involve the default registerServiceWorker for create-react-app. Removing it or unregistering it might be the solution, but what if having a Service Worker is desirable? It's good to have the pages and assets cached, except only when I upload an update.
Versioning might be an alternative, but I want to avoid manual updates and I am not 100% sure how it'll work cleanly with react yet.