I upgraded a large project to MVC4 RC today to try out the bundling and minification.
Before I had 8 static js files in script src tags in a partial view. A sample page ran in under .1 seconds consistently.
I added a bundle like this:
bundles.Add(New ScriptBundle("~/bundles/mybundle").Include(
"~/Resources/Core/Javascripts/jquery-1.7.1.min.js",
"~/Resources/Core/Javascripts/jquery-ui-1.8.16.min.js",
"~/Resources/Core/Javascripts/jquery.validate.min.js",
"~/Resources/Core/Javascripts/jquery.validate.unobtrusive.min.js",
"~/Resources/Core/Javascripts/jquery.unobtrusive-ajax.min.js",
"~/Resources/Core/Javascripts/bootstrap.min.js",
"~/Resources/Core/Javascripts/toolbar.js",
"~/Resources/Core/Javascripts/jquery-ui-timepicker-addon.js"))
In the partial I added this and the page load time increased to .5 seconds consistently with compilation debug as true and as false. @Scripts.Render("~/bundles/mybundle")
I then wrapped it with miniprofiler like this:
Dim profiler = MiniProfiler.Current
Using profiler.Step("bundling")
@Scripts.Render("~/bundles/mybundle")
End Using
The bundling step takes .4 seconds consistently.
The computer is a running VS2010 on modern hardware with a high end SSD drive and no nonstandard background tasks running. As soon as I delete the @scripts.render the page load time drops again to .1 seconds.
Is there a way to make the bundler cache or am I missing something that is making it be this slow?
This is a known bug with bundling in ASP.NET MVC 4 RC. The bundling is not being cached server-side.
The bug is described in detail here: http://todd-carter.com/post/2012/06/10/mini-me-fication-in-system-web-optimization-rc-is-evil/
There should be an update to the nuget MVC 4 RC package sometime in the week ending 17 June, 2012. (Source: https://twitter.com/howard_dierking/status/212725872904507392)
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