Using CdnFallbackExpression produces a version-less bundle if the CDN fails


When using bundle fallbacks, I notice that when the CDN fails, the fallback bundle does not have a version string attached to it.

This seems like it might be an oversight as if I move to a newer version of jQuery (or bootstrap or whatever) 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") _
        jQuery2.CdnFallbackExpression = "window.jQuery"

    End Sub
End Module
embedded with this call:
produces this output:
<script src="//broken.ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    (window.jQuery)||document.write('&lt;script src="/bundles/jQuery2"&gt;&lt;\/script&gt;');
<script src="/bundles/jQuery2"></script>
I would expect the fallback bundle to render as:
<script src="/bundles/jQuery2?v=somejunkuniquetothisversionofthefile"></script>
Otherwise, if I change the bundle to point to jquery-2.1.5.min.js, the cached version of jquery-2.1.4.min.js would still remain in the user's cache if they had visited the site anytime in the past year while the CDN was down.


RandM wrote Oct 1, 2015 at 10:48 PM

I'm not 100% sure, but I think this pull request from December may be a solution to the problem: