Monday, November 3, 2014

ASP.NET: Force client to update javascript files after each new build


How to force a client to update cached javascript files after each new build


Add build number property to your page class

Protected ReadOnly Property CurrentVersion() As Integer
            Return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build
        End Get
End Property

And update script source to utilize the build number property

<script src="Script/Functions.js?v=<%= CurrentVersion%>" type="text/javascript"></script>

After each new build script source url is changed so browser will update javascript-file to the cache