Search code examples
asp.net-mvc-4bundling-and-minification

How to remove querysting token of version generator using bundles in mvc 4


Hi i m using mvc4 application and using bundles to render scripts and css

below is how i created the bundle:

bundles.Add( new StyleBundle( "~/Content/css" ).Include(
                    "~/Content/bootstrap/css/bootstrap.css",
                    "~/Content/bootstrap/css/bootstrap-responsive.css",
                    "~/Content/site.css" ) );

Now it generates the bundle like this as i see in browser source:

<link href="/Content/css?v=8HZAB6C8ZnrIPYNFzMQKt0AR4AUsUYBjxPPkbGSRIZo1" rel="stylesheet">

What i want is to remove the "v" query string of version in the link.

Thanks


Solution

  • No because then browsers would cache stale versions of your bundle, as that query string is the fingerprint for when the contents change.

    We do have an item in our backlog to make it possible to customize how the fingerprint will show up in the url, but currently there's no way to just turn it off.

    A simple workaround is to just render out the path to your bundle explicitly since that will not change if you don't want the query string.