How do you improve your ASP.NET MVC application performance?
A compiled list of possible sources of improvement are below:
General
Caching
CompiledQuery.Compile()
OutputCacheAttribute
ActionResult
RouteName
PartialViews
Routing
Use Url.RouteUrl("User", new { username = "joeuser" }) to specify routes. ASP.NET MVC Perfomance by Rudi Benkovic
Url.RouteUrl("User", new { username = "joeuser" })
Cache route resolving using this helper UrlHelperCached ASP.NET MVC Perfomance by Rudi Benkovic
UrlHelperCached
Security
DAL
Load balancing
Utilize reverse proxies, to spread the client load across your app instance. (Stack Overflow uses HAProxy (MSDN).
Use Asynchronous Controllers to implement actions that depend on external resources processing.
Client side
Global configuration
If you use Razor, add the following code in your global.asax.cs, by default, Asp.Net MVC renders with an aspx engine and a razor engine. This only uses the RazorViewEngine.
ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine());
Add gzip (HTTP compression) and static cache (images, css, ...) in your web.config <system.webServer> <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/> </system.webServer>
<system.webServer> <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/> </system.webServer>
<pages buffer="true" enableViewState="false">
1.4m articles
1.4m replys
5 comments
57.0k users