I have a react application and each time a new version is deployed, some users don't get the new version due the browser cache.
Anyone can tell me how to clean the browser cache each time a new version of the software is deployed?
I have a react application and each time a new version is deployed, some users don't get the new version due the browser cache.
Anyone can tell me how to clean the browser cache each time a new version of the software is deployed?
The cache is a functionality provided by the browser to users. Because of security reasons, you can not clean the cache using javascript.
Cleaning cache means you can manipulate physical files from the users' computer and it is a huge security breach if one day you be possible to do that.
Check this answer to reinforce what I'm saying.
However, you can tell the browser to never cache your page like this (check this documentation as well):
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
Or change the files known by the browser by associating a hash tag name in all your files (javascript, images, fonts, ...) and change that hash each time you deploy a new version of your software like this:
<script src="script.js?version={versionNumber}">
<img src ="imageName.png=version={versionNumber}">