We have an application built on onReactJS and is deployed using S3 and CloudFront. We constantly get into the issue with clients where they are required to do hard refresh of the web app in order to get the latest SPA application.
To fix this issue I came across following article.
Append reload notice on create-react-app & registerServiceWorker.js
The approach in this article successfully raises an event called 'newContentAvailable' on all three browser i.e. FF, Chrome and Safari. When this event is raised the logic attempts to reload the updated version using window.location.reload(true)
. This updates FF and Safari successfully but Chromes still get the older version.
I have tried to used a different approach for reloading in Chrome but no luck. I came across the following code when searching about this issue
$.ajax({
url: window.location.href,
headers: {
"Pragma": "no-cache",
"Expires": -1,
"Cache-Control": "no-cache"
}
}).done(function () {
window.location.reload(true);
});
I am not sure what I am doing wrong here. Please help.