In this we will discuss about how can we increase the performance of website that using ASP.NET MVC.
1. Remove Unused view engines
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
}
2. Deploying Production Code in Release Mode
Make sure your production application always runs in release mode in the web.config
| <compilation debug=”false”></compilation> |
| <configuration> <system.web> <deployment retail=”true”></deployment> </system.web> </configuration> |
3. Use OutputCacheAttribute when appropriate
MVC will not do any View Look-up Caching if you are running your application in Debug Mode
[OutputCache(VaryByParam = "none", Duration = 3600)]
public ActionResult Categories()
{
return View(new Categories());
}
4. Use HTTP Compression
Add gzip (HTTP compression) and static cache (images, css, …) in your web.config
| <system.webserver><urlcompression dodynamiccompression=”true” dostaticcompression=”true” dynamiccompressionbeforecache=”true”></urlcompression>
</system.webserver>
|
5. Avoid passing null models to views
6. Remove unused HTTP Modules
7. ASP.NET MVC ACTION FILTER – CACHING AND COMPRESSION
Source: ASP.NET MVC ACTION FILTER – CACHING AND COMPRESSION
8. Un controlled actions
9. Put repetitive code inside your PartialViews
6. Remove unused HTTP Modules
7. ASP.NET MVC ACTION FILTER – CACHING AND COMPRESSION
Source: ASP.NET MVC ACTION FILTER – CACHING AND COMPRESSION
8. Un controlled actions
9. Put repetitive code inside your PartialViews
10. Add an Expires or a Cache-Control Header
| <configuration><system.webServer>
<staticContent>
<clientCache cacheControlMode=”UseExpires”
httpExpires=”Mon, 06 May 2013 00:00:00 GMT” />
</staticContent>
</system.webServer>
</configuration>
|
11. Un controlled actions
protected override void HandleUnknownAction(string actionName)
{
RedirectToAction("Index").ExecuteResult(this.ControllerContext);
}
12. Put Stylesheets at the Top
13. Put Scripts at the Bottom
14. Make JavaScript and CSS External
15. Minify JavaScript and CSS
16. Remove Duplicate Scripts
17. No 404s
18. Avoid Empty Image src
19. Use a Content Delivery Network
Use either Microsoft, Google CDN for referencing the Javascript or Css libraries
20. Use GET for AJAX Requests
21. Optimize Images
13. Put Scripts at the Bottom
14. Make JavaScript and CSS External
15. Minify JavaScript and CSS
16. Remove Duplicate Scripts
17. No 404s
18. Avoid Empty Image src
19. Use a Content Delivery Network
Use either Microsoft, Google CDN for referencing the Javascript or Css libraries
20. Use GET for AJAX Requests
21. Optimize Images

0 comments:
Post a Comment