I'm working on existing web applications built using ASP.NET Core MVC and ASP.NET web forms technologies.
Existing web pages has references to custom .js files for client-side validations and other logic.
When I make changes to one of the .js file and deploy to Production, end users are not able to see the new script changes as their browser web pages are being cached and request them to manually clear browser cache.
However, my managers are against this and saying we can't ask all 5000 user to clear browser cache individually everytime we deploy scripts changes.
Please advise whats the best way to handle this issue.
Amit MohantyPosted Feb 12, 2024, 6:08 AM
You can implement cache busting techniques in your application by appending a query string parameter with a unique value to the URL of your JavaScript files each time they are updated.
For more info check the below links.
https://vaibhavbhapkarblogs.medium.com/cache-busting-in-net-5efaeaf4288f
https://stefanolsen.com/posts/cache-busting-with-asp-net-mvc/
https://softwareparticles.com/cache-busting/
Muhammad Imran AnsariPosted Feb 12, 2024, 3:55 AM
There is no scenario in which a browser allow to clear its cache, as this would be a security risk. Such functionality could be easily exploited, and if a browser were to support it, I would promptly remove it from the computer. You might also want to consider turning off auto-complete on form fields as well.
Instead, what you can do is tell the browser not to cache your page by sending the appropriate headers or utilizing specific meta tags.