Author

Hi there!

I'm Anil Kumar M.S. A technology enthusiast living in Mysore, India. I'm Passionate about .Net, Web Apps, Cloud, Application design and Architecture, Ux, Javascript and Windows Phone.

A Microsoft Certified Technology Specialist and also a Professional Developer in .Net 4 Web. I like travelling, doing Adventure & Love food.

Let's be friends !



Webpage : www.msanil.com
×

Thursday, November 03, 2011

ASP.Net Applications Performance Improvement - 1

Thursday, November 03, 2011

Recently i attended a webcast series on Optimizing ASP.NET Applications presented by Ranjith Pallath (Technical Consultant, Microsoft GPS). Ranjith mentioned many things we can do to speed up existing web applications and also few things for developers to follow when developing new applications. Many readers of my blog wanted me to post some tips on performance improvements so thought of posting the tips i learnt from Ranjith.



Basically there are two ways to get benifitted. Performance tuning your application at Client Side and tuning it from Server Side.

In this post, we shall look into the client side improvements we can do. Here we go.

Resize Original images using a photo editor. Do Not scale down the width and height by specifying the properties in tags and making it happen only in browser.
Use ySlow or Google Page Speed extensions for analysing the page and its performance.
Write JavaScripts and includes at bottom of your page. Load HTML first. Never load scripts before UI. Even if there javascript errors, it doesn’t disturb your html rendering this way.
User 'defer' attribute in <script> tags.  defer="defer" is a new standard. So, JS is rendered only after html is rendered.  JavaScript files do not get downloaded at beginning but on demand.
Use CDN instead of keeping files on your server and just point files to those URL’S.  Say JQuery files and CSS, Images.MS Cloud or Google has CDN. CDN Copies your data to multiple data centers and content gets served from your nearest area and it’s fast.  Don’t use CDN for intranet app. Use only for websites having Internet Access. In asp.net 4.0, option  enableCDN is present. CDN Saves bandwidth, caching the files for 365 days! Unless you clear it. This property  Looks files only in MS Servers. A point to remember.
Do not put script manager tags in master pages. It is Not advisable.
Minify Javascripts and CSS using tools. Have a look at Microsoft Ajax Minifier from code project. Only do minify in production. Things become unreadable after doing it. So.
Use Fidler to understand the network profiling.
Using JQuery is better than Using MS Ajax for now if you can achieve something with both.
Implement caching for application (use static and dynamic content tags in web.config) example <system.webserver><staticContent>
In IIS 7 or above, enable Output Caching for website/virtual directories. Use handlers and modules in case you use IE6.

Use compression with session variables. Make <sessionState compressionEnabled="true"/> in system.web of web.config. This is in  asp.net 4.0. Add Just 1 line tag and relax.

Use Compression in Webserver. Compression mostly Works with GZip. Compression works for http response so works for static and dynamic pages both.
Use Seadragon for smart pixelated loading of images.
Minimize the number of requests made to server. Use Bundling instead of making many requests. Use tool called SQUISH IT. It is like you combine 2 or more css files at server and render as 1 at client side. This can be done for javsacripts also. Download SQUISH IT.
  • To your project, add a dll reference and code like SquishIt.Framework.Bundle.Css() ..Add()... This combines many css files at runtime and sends 1 file in response. Google it to find how to use it. This can also be done for JS files. This makes 1 request instead of 2. Debug mode should be false in web.config to use SQUISH IT.
  • Bundlers are just http handlers and you can write your own. Debug mode can be false just in production not necessary in dev.


In the next post, we shall see what we can do at server side to improve the performance.

Author : Anil Kumar M.S
A technology enthusiast living in Mysore, India.
You can connect with me on Twitter @MSGuyTweets or on Facebook.
Email me at ms.anil.kumar@gmail.com


Was this post useful?