I used to put "?v=n" at the end of my scripts references, like:
<script type="text/javascript" src="@Url.Content("~/Scripts/Foo.js")?v=2"></script>
Each time I edited a .js, I added 1 to that versioning, eg:
<script type="text/javascript" src="@Url.Content("~/Scripts/Foo.js")?v=3"></script>
I decided this couldn't continue being like that (I have too many scripts now), so I started using the ASP.NET MVC bundling feature (BundleConfig, BundleCollection, RegisterBundles
, et c).
Indeed a version is automatically assigned to the bundle:
<script src="/Scripts/Bundles/Foo?v=EjpuCsTAfNN9NMv5E8hER41p25Zj9w6ncqWRsYdqQUY1"></script>
My question is:
When does that version change? Can I rely on this? How does it work internally?
I might be wrong but one time I had to manually refresh the browser so that the script was updated, because the minor change I did to the script didn't took effect on the version.
What could have caused this?
Are minor changes considered in the versioning?
The version of bundle is a SHA256 based hash
of all bundled content.
So if you will change any data of bundled files - version will be changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With