How asp.net Bundling works internally -
i curious know how asp.net bundling works.
i know we've add scripts , css , images bundle browser initiate single request resources.
i 've confusion how pages refer these bundled resources client browser.
let's take @ happens when use bundling in system.web.optimization.
in example used "empty asp.net mvc 4 template" , grabbed latest "microsoft.aspnet.web.optimization" package nuget.
i proceeded register 2 javascript files. 1 jquery , bootstrap.
public static void registerbundles(bundlecollection bundles) { var javascriptbundle = new bundle("~/bundles/javascripts") .include("~/scripts/jquery-{version}.js") .include("~/content/bootstrap/js/bootstrap.js"); bundles.add(javascriptbundle); }
now have our setup done, let's see happens when view page.
you can see both javascript files included do. happens when have "debug" flag set in web.config.
let's turn false , see happens now.
now see single reference added unique looking location. clicking on it, see spits out minified , combined version of both of javascript files referenced in our bundle.
this funny query string parameter v=lommcaixrkwmovsm8ok8q5jvmufqui3fiirvjqc33hs1 reference our content , can see no matter how many times hit website, it's going stay same. (i.e. refreshing multiple times).
let's see fiddler says reference our javascript files.
we can see response cachable. cache expiration has been set "wed, 26 mar 2014 06:49:06 gmt". year today.
subsequent requests resource read browser's cache. "this http/304 response indicates existing cached response remains fresh. cache-lifetime headers on http/304 response may used update cached response's freshness."
if require more information, see http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification
Comments
Post a Comment