Does MVC4 bundling and mimification do any caching

2019-07-03 11:30发布

问题:

I would like to use the bundling and mimification features of MVC4 but I am concerned about the mimification. Is it the case that every time there is a request for css and javascript from a client that the bundling/mimification process works. If so then is there not a CPU overhead each time?

回答1:

Quote:

Bundling and minification primarily improve the first page request load time. Once a webpage has been requested, the browser caches the assets (JavaScript, CSS and images) so bundling and minification won’t provide any performance boost when requesting the same page, or pages on the same site requesting the same assets.

So the assets will be cached by the browser and not requested on subsequent pages so there will be no performance hit.

Remark: There's a bug in ASP.NET MVC 4 RC which doesn't perform caching at the server side which will hopefully be fixed in the RTM. So when calling the @Scripts.Render helper in the view there will be a performance hit everytime.