Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC4 RC script bundling very slow

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?

like image 491
ericdc Avatar asked Jun 12 '12 15:06

ericdc


1 Answers

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)

like image 77
Brad Leach Avatar answered Oct 27 '22 14:10

Brad Leach