We have a production application with several aspx and cshtml pages. These pages refer to multiple javascripts which gets changed frequently.
Since we are using CDN, Whenever a change is made to any of the javascript file, we manually version it across all the aspx/cshtml it is being referred from. For example: if abc.aspx has [script src="abc.js?v=1"] and we make changes to abc.js, we manually have to change abc.aspx like [script src="abc.js?v=2"]
This becomes very difficult to do with several aspx and javascript/css files.
I read it here: force browsers to get latest js and css files in asp.net application
But there are few problems in suggested approaches:
- It looks like the solution would version js for each request made by a user. This is not correct. Since ours is performance oriented website, we need to cache it unless it gets changed.
- if at all its @Html.IncludeVersionedJs("/MyJavascriptFile.js") looks only for mvc. what is web form version to do this?
Basically we want to avoid manually versioning javascript references and build something intelligent enough to detect if any of javascript has changed in my solution, it automatically updates its corresponding references too with new versions.