Base solution for your next web application
Open Closed

Force scripts reloading in clients #786


User avatar
0
ofir1234 created

Hi. I've noticed that client browsers aren't refreshing .js files and .html files after I publish a new version of my ASP.Net Boilerplate based website. This is because the browsers have some caching, and I need do something like that in order to tell the clients that new .js version is here : <a class="postlink" href="http://stackoverflow.com/questions/32414/how-can-i-force-clients-to-refresh-javascript-files">http://stackoverflow.com/questions/3241 ... ript-files</a>

I wonder if you have any magic thing in ASP.Net boilerplate to force clients to reload new .js and .html files when I deploy new versions.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    There are 2 ways actually.

    If you include script using Html.IncludeScript like

    @Html.IncludeScript("~/Abp/Framework/scripts/libs/abp.signalr.js")
    

    it is going to add a parameter to the end of script file resulting like

    <script src="/Abp/Framework/scripts/libs/abp.signalr.js?v=635911474900548694" type="text/javascript"></script>
    

    Second way is to add this parameter manually if you dont want to use Html.IncludeScript syntax. In this way you can change your script include like this:

    <script src="~/AbpScripts/GetScripts?v=@(Clock.Now.Ticks)" type="text/javascript"></script>
    

    I hope this helps.