I have recently updated a new feature in my React JS project and deployed it to my production server. However, I’m experiencing an issue where the changes are only reflecting in certain browsers.
Specifically, if I open my website in a browser for the first time after the deployment, the changes are successfully displayed. However, if I had previously opened the website in the same browser and then try to access the updated page, the changes are not being reflected. I have tried hard refreshing the page and clearing all browser history, but the issue persists.
To deploy the project, I followed these steps:
- Ran the command npm run build to generate a production-ready build.
- Used the scp command to push the code into the production server.
- Updated the NGINX server’s project configuration to point to the newly created build folder as the root directory.
I hard refreshed cleared all the history, tried deployed various builds by slightly modifying the code. but still no use.
2
Answers
You can change the value of the query parameter (v=1) every time you deploy a new version of your app, or use some automated tool to generate a unique value based on the file content or timestamp.
This situation might happen for multiple reasons but caching the Html and Js files in the server or client usually is the main problem.
<meta http-equiv="Cache-control" content="no-cache">
ServiceWorker
, it has a life cycle and preaches almost every file in cache storage. (you can find it in browser developer mode -> application tab). and even if you unregister the service worker it’s not removed in some cases.At the end make sure you build and publish correctly. wish you luck