asp.net-optimization

Can you pre-cache ASP.NET Bundles?

亡梦爱人 提交于 2019-12-20 12:33:29
问题 Every time I deploy an MVC web application my server has to re-cache all js and css bundles. Because of this it can take several seconds for the first view to render after deploying. Is there a way to pre-cache bundles? After all, the files are static at compile time. 回答1: Solution To fix we replaced the default memory cache with caching that persisted beyond the App Pool life. To do this we inherited from ScriptBundle and overrode CacheLookup() and UpdateCache() . /// <summary> /// override

Cassette bundles vs MVC4 bundles

只愿长相守 提交于 2019-12-20 09:46:40
问题 I am currently working on a prototype ASP.NET MVC 3 solution that will be used as a base for several project rewrites (from web forms). One of the goals that I have is to implement some script management across application as opposed to none that we currently have. MVC 3 has a flaw IMHO: if you need specific script specified on a partial view or template view - you might end up either losing control over where script block is located in rendered HTML or having to specify every single

Bundle file location in ASP.NET MVC

戏子无情 提交于 2019-12-18 12:59:17
问题 Where are the generated bundle files placed? bundles.Add(new ScriptBundle("~/bundles/jqueryall") .IncludeDirectory("~/scripts/", "*.js", true) 回答1: There are no files, bundles are stored in-memory. Can you please explain why you expect the bundles to be files? :-) 回答2: They are bundled up dynamically (in Memory I assume) and served to the client being sent down to the client as a single item (you should the single JS file see it if you use fiddler of F12 => Network). 来源: https://stackoverflow

MVC4 Beta Minification and Bundling: Ordering files and debugging in browser

*爱你&永不变心* 提交于 2019-12-18 11:52:29
问题 I've started using bundling and minification included with the MVC4 Beta. I'm running into a few issues with it: For one thing, if I use the classic <script src="Folder/js" type="text/javascript"/> bundling, it seems like I have to rename my files to make sure they're bundled in the proper order. Let's say I have three javascript files: "ants.js", "bugs.js", "insects.js" ants.js depends on bugs.js bugs.js depends on insects.js Default bundling seems to bundle them in alphabetical order. To

MVC4 Bundling Cache Headers

痞子三分冷 提交于 2019-12-18 11:04:40
问题 I want to change the cache headers sent from a bundle request. Currently it is varying by User-Agent but I don't want it to, is there a way to change the headers sent by a bundle request? After a quick look in the System.Web.Optimization assembly I can see the headers get set in Bundle.SetHeaders which is a private static function so I don't think its possible although I would love to be proven wrong. 回答1: This isn't something that we currently expose today. We only expose the Cacheability

Async loading of javascript files using MVC4 Bundling and HTML5 async attribute

泪湿孤枕 提交于 2019-12-18 10:48:13
问题 HTML5 has an async attribute for script files, to enable async loading. <script type="text/javascript" src="myScript.js" async></script> I can take advantage of this with my MVC4 bundling by referencing the bundle like so. <script type="text/javascript" src='@Scripts.Url("~/bundles/jquery")' async></script> But what this does mean is my scripts are bundled even when in debug mode. So how can I take advantage of bundling and the async attribute without loosing non-minification when in debug.

Why does ResolveBundleUrl not work for custom folders? (MVC Beta 4)

只愿长相守 提交于 2019-12-18 03:11:39
问题 From a brand-new ASP.NET MVC 4 Beta Web Application, I'm re-arranging my folders to match Rob Conery's VidPub.Web example Specifically, this means that the final directory structure for content looks like this VidPub.Web | ---Public | |---Images |--- *.png |---javascripts |--- *.js |---stylesheets |----themes |---base |--- images |--- *.css |----site.css However, when I change the following lines in _Layout.cshtml <link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl( "~

Why does ResolveBundleUrl not work for custom folders? (MVC Beta 4)

喜你入骨 提交于 2019-12-18 03:11:22
问题 From a brand-new ASP.NET MVC 4 Beta Web Application, I'm re-arranging my folders to match Rob Conery's VidPub.Web example Specifically, this means that the final directory structure for content looks like this VidPub.Web | ---Public | |---Images |--- *.png |---javascripts |--- *.js |---stylesheets |----themes |---base |--- images |--- *.css |----site.css However, when I change the following lines in _Layout.cshtml <link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl( "~

How to upload bundled and minified files to Windows Azure CDN

我的梦境 提交于 2019-12-17 17:33:32
问题 I'm using the ASP.NET MVC 4 bundling and minifying features in the Microsoft.AspNet.Web.Optimization namespace (e.g. @Styles.Render("~/content/static/css") ). I'd like to use it in combination with a Windows Azure CDN. I looked into writing a custom BundleTransform but the content is not optimized there yet. I also looked into parsing and uploading the optimized stream on runtime but that feels like a hack to me and I don't really like it: @StylesCdn.Render(Url.AbsoluteContent( Styles.Url("~

MVC4 - Bundling does not work when optimizations are set to true

做~自己de王妃 提交于 2019-12-17 10:23:02
问题 I wonder what I don't do correct here. I am using ASP.NET C# MVC4 and I want to take use of new css/js optimization feature. Here is my HTML part @Styles.Render("~/content/css") Here is my BunduleConfig.cs part bundles.Add(new StyleBundle("~/content/css").Include( "~/content/css/reset.css", "~/content/css/bla.css")); // BundleTable.EnableOptimizations = true; Output (works): <link href="/content/css/reset.css" rel="stylesheet"/> <link href="/content/css/bla.css" rel="stylesheet"/> However