I'm trying to figure out how the easiest way would be to force endusers browser to clear cache.
We are working in visual studio with .Net WebForms and AngularJs
So every time we deploy our .Net project to test or production enviroment we got problems with cache saving old javascript and hides new implementation...
I know a couple solutions but I wanna see if there are any other?
Thanks in advance!
Right click in this page and select view source, you will see static files suffixed as follows:
<script src="//cdn.sstatic.net/Js/stub.en.js?v=b1fcfe635df7"></script>
Basically this is kind of the best method, generate some suffix and append that to the end of all of your static files as a querystring parameter. That will force the browser into thinking that the file is new, i.e. if the querystring has changed...
The rub here though is how often do you change those files... how often do you want to force the user to download new static files... using a generated timestamp could force the user to download the file everytime they visit the site, often not ideal.... Maybe use the web.config date or something like it.
you can add below settings in web.config to disable caching
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>