Bundling and Optimizing

Download this episode

Download Video


Visual Studio 2012 will introduce optimization features for all ASP.NET project types. Howard Dierking shows you how to drastically shrink your response size as well as increase page download speed and site performance.





Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Sunil Unnithan

      This is great introduction to web optimization. I have one question regarding the extensibility model. I already have MSBuild target hooked up as part of VS2010 build process to generate minified javascript and css files using yuicompressor. What I would like to use is the caching feature of web optimization to generate unique url based on the hash of the minified files.

      Is there any way to hook into web optimization model to not use bundling/minification and just leverage the caching module?

      Sunil Unnithan

    • User profile image

      Hi Sunil - yes, it's not pretty, but you should be able to use just the version stamping piece by doing 3 things:

      1. create a bundle for the javascript/css resource that you want versioned
      2. create a custom IBundleTransform which does nothing other than sets the media type - we actually have this in the fx (look at the NoTransform class in reflector), but unfortunately it's internal
      3. create and register the bundle in BundleConfig

      We'll also look into making more modular support easier in future versions.  Hope this helps.


    • User profile image

      Hi there,

      Thanks for the great video, I do have one question though, it's pretty hard to know on NuGet what is the latest bundling version that will work with ASP.NET MVC 3?

      On NuGet there is:
      1) ASP.NET Optimization - Bundling 0.1
      2) Microsoft ASP.NET Web Optimization Framework
      1.0.0-beta3 (which has a later date than the first one)
      3) Where is the version you are using?

      Also the cdn feature isn't available in either of these packages
      bundles.UseCDN <-- not found

      It would be great if you could provide the version number or a link to which NuGet package you are actually using?

      Thanks for your time and effort

      Regards DotnetShadow

    • User profile image
      Sunil Unnithan

      Great! Thanks for the tip Howard. Does the caching module generate correct cache control header "Cache-Control: no-transform" for the bundle files?

      Sunil Unnithan

    • User profile image

      @DotnetShadow: We renamed the package Microsoft.Web.Optimization to Microsoft.AspNet.Web.Optimization - that's why those 2 different packages exist.  When we released the later version of Microsoft.AspNet.Web.Optimization, we also updated the Microsoft.Web.Optimization package version such that it contained no actual content - just a dependency to the renamed package.  As such, it basically acts like a redirect.

      For the different versions of Microsoft.AspNet.Web.Optimization, we follow the conventions outlined in the Semantic Versioning specification (http://semver.org).  Therefore, we published a couple different pre-release versions and recently the first stable version (1.0.0).

      The CDN feature is available in 1.0.0 (http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0) - I had put some code on my blog that referenced this code before we had pushed the final package to nuget.org.  Sorry for the confusion there.

    • User profile image

      @Sunil Unnithan: no - need to look at adding this header. The plan going forward is that we'll provide you the ability to control much more about the response message from within your transform than we do today.

    • User profile image

      With the SquishIt library available and easy to use/setup, what is the benefit of using this solution? I'll play around with it when I have time, but SquishIt was super-easy to set up, and is very clear in its usage.

    • User profile image
      Daniel Plomp

      Hi, nice video.
      Is it also possible to add a whole folder of e.g. css files to a bundle at once? So when you have like 5 files you can just refer to a folder?

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.