1

When using bundle fallbacks in MVC, I notice that when the cdn fails, the fallback bundle does not have a version string attached to it. Is there a way to force the version string to appear?

My concern is that if I move to a newer version of jQuery (or bootstrap or whatever) that the script will not be updated on the client as it could still be in the cache (since by default the cache length is 1 year).

For example, this bundle config:

Public Module BundleConfig
    Public Sub RegisterBundles(ByVal bundles As BundleCollection)

        BundleTable.EnableOptimizations = True
        bundles.UseCdn = True

        Dim jQuery2 = New ScriptBundle("~/bundles/jQuery2", "//broken.ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js") _
                      .Include("~/Scripts/jquery-2.1.4.min.js")
        jQuery2.CdnFallbackExpression = "window.jQuery"
        bundles.Add(jQuery2)

    End Sub
End Module

embedded with this call:

@Scripts.Render("~/bundles/jQuery2")

produces this output:

<script src="//broken.ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
    (window.jQuery)||document.write('&lt;script src="/bundles/jQuery2"&gt;&lt;\/script&gt;');
</script>
<script src="/bundles/jQuery2"></script>

Is this a bug, an oversight, or am I missing something to get the version string to appear?

I would expect the fallback bundle to render as:

<script src="/bundles/jQuery2?v=somejunkuniquetothisversionofthefile"></script>

How can I achieve this?

I am aware that this question has been asked before, but the author hasn't updated his question to include any code, so I am doing so here.

Community
  • 1
  • 1
hobwell
  • 538
  • 1
  • 8
  • 26
  • Well, in general, this is the wrong place to ask. If you suspect it to be a bug, post an issue to the CodePlex site: https://aspnetoptimization.codeplex.com/. Short of that, the best guess I can give you is that since the actual bundle file is only a fallback, they left out the cache-buster to force it to cache, so that those times when the CDN is down, your site may still get to skip the request. – Chris Pratt Oct 01 '15 at 18:32
  • 1
    @ChrisPratt I had that thought as well, but if it was deliberate, it seems like an oversight. Thanks for the direction regarding the CodePlex, I will take my question [there](https://aspnetoptimization.codeplex.com/workitem/168). – hobwell Oct 01 '15 at 20:27

0 Answers0