How to optimize an ASP.NET MVC website with these 20 points. PART-1
After reading this, one would have engough knowledge to developed an ASP.NET MVC site which will definately serve the purpose of its creation.
A survey mentioned that in 2020 if you search on google and from the search results, you click any of the suggestions sites. A normal user does not wait more than 4 sec to load and switch to the next search results. Until unless you are going to log in on a Social site. Naturally, no one wants to wait to load a site especially when the user on a mobile device.
In this article, I will try to explain all the main factors (actually not every) which must be taken care of by the web developer who writes codes for the ASP.NET MVC website and for the architect who designs the whole system for end-users. Actually, there are dozen ways to optimize an ASP.NET MVC site but I will only try to focus on the most common and important ones.
Let's first list it down and then I will provide the detail for each.
- Follow the Microsoft guide for design the modern website with ASP.NET MVC.
- Application Architecture should be clean
- Application Caching should be enabled (Views or especially for partial views).
- Always optimize the images.
- Use the Bundling and Minification religiously for JS and CSS files.
- Deploy in Release mode only, Debug mode hides the performance issues.
- Load only required data for a page
- Always use Client-side validations
- Take control of Server-side calls (database).
- Prefer ADO.NET over Entity Framework
- Use CDN if possible
- Use Zip/Compression via IIS
- Always try to use AJAX for getting data.
- Hierarchal Loading, CSS First, and JS at the END.
- Shrink Image and use of Sprite images
- Control the count of HTTP requests
- Use Visual Studio Profile or to discover memory leaks and performance issues.
- Use 3rd party online tools to check the performance before rolling out.
- Keeps the cookies size small, as cookies are sent to the server for every request.
- If using Razor, then always use the clear command in global.asax.cs
All the above points are not final points and make you guarantee, there are a lot of others. But as I have in the .NET world for a decade so in personal experience recommend that if one should care for above 20 points the site would be in much better response time than usual.
In part 2, I will explain all the above 20 points in detail.
Stay Haelthy and Enjoy Coding!