Question

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?

Was it helpful?

Solution

How does .net generates the version of bundle?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top