<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5127893340841894477</id><updated>2011-11-28T05:05:34.525+05:30</updated><category term='ASP.Net'/><category term='Visual Studio IDE'/><category term='Sports'/><category term='Known Errors'/><category term='Javascript'/><category term='OOPS'/><category term='DataBase'/><title type='text'>How in .Net</title><subtitle type='html'>This Blog is Used as a Resource for the Dotnet Requirement</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dotnetarmy.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-863163260280121908</id><published>2008-11-24T11:30:00.006+05:30</published><updated>2009-06-18T10:00:41.728+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Sending Mail with ASP.Net</title><content type='html'>&lt;strong&gt;&lt;strong&gt;&lt;strong&gt;Sending Email with ASP.NET&lt;/strong&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;Well Today’s website is almost incomplete without the Email feature as any kind of website either informative and a database driven or etc everyone require the email sending and may require the email communication. So, therefore I will demonstrate how to send email via ASP.NET with HTML mail and attachments. &lt;br /&gt;We require an installation of Microsoft's .NET Framework SDK on a Web server. &lt;br /&gt;Prerequisite ::-&gt; C# programming.&lt;br /&gt;&lt;strong&gt;The Smooth way&lt;/strong&gt;&lt;br /&gt;There always is a way that can be classified under the heading 'Quick and Dirty'. And I again want to begin with this way because we can test the server configuration quite easily without having to take any side effects into consideration (SimpleMail.aspx). &lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;@Page Language="C#" &lt;br /&gt;@Import Namespace="System.Web.Mail"&lt;br /&gt;string strTo = "Pradeep.bisht@XYZ.com";&lt;br /&gt;string strFrom = "webmaster@XYZ.com";&lt;br /&gt;string strSubject = "Hi Crazy Programmer";&lt;br /&gt;&lt;br /&gt;SmtpMail.Send(strFrom, strTo, strSubject,&lt;br /&gt;  "Dear Mr.XXX you seems to be awesome developer,WelCome to XYZ ");&lt;br /&gt;Response.Write("Email was stacked");&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;What exactly is going ?, The Complete email is supported by the namespace System.Web.Mail.In this namespace we find the class SmtpMail, whose static Send method can accept four parameters: &lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;SmtpMail.Send(From, To, Subject, BodyText);&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;As I said, it is very simple, but it has one thing in common with the more functional email sending options: the SMTP Server must be the locally installed SMTP Service of the IIS - no other can be used. In this respect the email support of ASP.NET is identical with the CDONTS of ASP 3.0. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sending HTML Email&lt;/strong&gt;&lt;br /&gt;But now we leave this all too simple method behind and look at a very functional object: the MailMessage class. This class 'encapsulates' everything one can wish for in an email - the following example demonstrates the use with a short HTML email (SimpleMailMessage.aspx). &lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;@Page Language="C#" &lt;br /&gt;@Import Namespace="System.Web.Mail" &lt;br /&gt;&lt;br /&gt;MailMessage msgMail = new MailMessage();&lt;br /&gt;&lt;br /&gt;msgMail.To = "pradeep@XYZ.com";&lt;br /&gt;msgMail.Cc = "webmaster@XYZ.com";&lt;br /&gt;msgMail.From = "webmaster@XYZ.com";&lt;br /&gt;msgMail.Subject = "Hi Pradeep, Nextmail";&lt;br /&gt;&lt;br /&gt;msgMail.BodyFormat = MailFormat.Html;&lt;br /&gt;string strBody = "&lt;b&gt;Hello World&lt;/b&gt;" +&lt;br /&gt;   " &lt;font color=\"red\"&gt;ASP.NET&lt;/font&gt;";&lt;br /&gt;msgMail.Body = strBody;&lt;br /&gt;&lt;br /&gt;SmtpMail.Send(msgMail);&lt;br /&gt;&lt;br /&gt;Response.Write("Email was stacked");&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The code looks much better now and above all, there are significantly more options than there are in the first Send method. First we set the To, From and Subject properties of the MailMessage then we set the BodyFormat to the value Html out of the MailFormat enumeration. And then we already are set to send a HTML email. &lt;br /&gt;Worth mentioning is the fact that all overloads of the Send method do not have return values about the success of dispatching the email message. The reason for this is that the emails simply are written into the Pickup folder of the Inetpub directory from where they are read and then sent by the SMTP Service. Failed emails (dispatching errors) also are written into files, this time however in the Badmail folder. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sending Attachments&lt;/strong&gt;&lt;br /&gt;With certain email components, sending attachments can be a bit of an adventure. With .Net, it is just another easy to use component: MailAttachment. The following code demonstrates how an attachment can be added to the MailMessage (MailAttachment.aspx). &lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;@Page Language="C#"&lt;br /&gt;@Import Namespace="System.Web.Mail" &lt;br /&gt;&lt;br /&gt;MailMessage msgMail = new MailMessage();&lt;br /&gt;&lt;br /&gt;msgMail.To = "pradeep@XYZ.com";&lt;br /&gt;msgMail.From = "webmaster@XYZ.com";&lt;br /&gt;msgMail.Subject = "Test Attachment ";&lt;br /&gt;&lt;br /&gt;msgMail.BodyFormat = MailFormat.Text;&lt;br /&gt;msgMail.Body = "find the attachment!";&lt;br /&gt;msgMail.Attachments.Add(new MailAttachment("c:\\temp\\Weekly-report.pdf"));&lt;br /&gt;&lt;br /&gt;SmtpMail.Send(msgMail);&lt;br /&gt;&lt;br /&gt;Response.Write("Email was stacked ");&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The line &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;msgMail.Attachments.Add(new MailAttachment("c:\\temp\\weekly-report.pdf"));&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;might also be programmed as follows &lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;MailAttachment maAttach = new MailAttachment("c:\\temp\\weekly-report.pdf");&lt;br /&gt;IList msgAttachments = msgMail.Attachments;&lt;br /&gt;msgAttachments.Add(maAttach);&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The point I want to make is that the attachments are handled through an IList interface (to be found in the System.Collections namespace) - and this supplies the Add method. This IList interface can also be used to enumerate or delete attachments. An additional remark has to be made about the constructor of MailAttachment: the encoding type can be set (this is probably rarely needed).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-863163260280121908?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/863163260280121908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/863163260280121908'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/sending-mail-with-aspnet_24.html' title='Sending Mail with ASP.Net'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-5553082276258009688</id><published>2008-11-17T17:20:00.002+05:30</published><updated>2008-11-17T17:24:03.476+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><title type='text'>Static constructor</title><content type='html'>C# supports two types of &lt;strong&gt;constructor&lt;/strong&gt;, a class constructor (&lt;em&gt;static constructor&lt;/em&gt;) and an instance constructor (&lt;em&gt;non-static constructor&lt;/em&gt;).&lt;br /&gt;&lt;br /&gt;Static constructor is used to initialize static data members as soon as the class is referenced first time, whereas an instance constructor is used to create an instance of that class with &lt;new&gt; keyword. A static constructor does not take access modifiers or have parameters and can't access any non-static data member of a class.&lt;br /&gt;&lt;br /&gt;Since static constructor is a class constructor, they are guaranteed to be called as soon as we refer to that class or by creating an instance of that class.&lt;br /&gt;&lt;br /&gt;You may say, why not initialize static data members where we declare them in the code. Like this :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;private static int id = 10;&lt;br /&gt;private static string name = "jack";&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Static data members can certainly be initialized at the time of their declaration but there are times when value of one static member may depend upon the value of another static member. In such cases we definitely need some mechanism to handle conditional initialization of static members. To handlesuch situation, C# provides static constructor.&lt;br /&gt;&lt;br /&gt;Let me explain you with examples :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;//File Name : Test.cs&lt;br /&gt;using System;&lt;br /&gt;namespace Constructor&lt;br /&gt;{&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;//Declaration and initialization of static data member &lt;br /&gt;private static int id = 5;&lt;br /&gt;public static int Id&lt;br /&gt;{&lt;br /&gt;get&lt;br /&gt;{&lt;br /&gt;return id;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public static void print()&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("Test.id = " + id);&lt;br /&gt;}&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;//Print the value of id &lt;br /&gt;Test.print();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;br /&gt;In the above example, static data member &lt;id&gt; is declared and initialized in same line. So if you compile and run this program your output would look similar to this :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Test.id = 5&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Lets create one more class similar to class Test but this time the value of its static data member would depend on the value of static data member &lt;id&gt; of class Test.id. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;//File Name : Test1.cs&lt;br /&gt;using System;&lt;br /&gt;namespace Constructor&lt;br /&gt;{&lt;br /&gt;class Test1&lt;br /&gt;{&lt;br /&gt;private static int id ;&lt;br /&gt;//Static constructor, value of data member id is set conditionally here. &lt;br /&gt;//This type of initialization is not possible at the time of declaration.&lt;br /&gt;static Test1()&lt;br /&gt;{&lt;br /&gt;if( Test.Id &lt; 10 )&lt;br /&gt;{&lt;br /&gt;id = 20;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;id = 100; &lt;br /&gt;}&lt;br /&gt;Console.WriteLine("Static&lt;Class&gt; Constructor for Class Test1 Called..");&lt;br /&gt;}&lt;br /&gt;public static void print()&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("Test1.id = " + id);&lt;br /&gt;}&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;//Print the value of id &lt;br /&gt;Test1.print();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;br /&gt;As you can see in the above static constructor, static data member &lt;id&gt; is initialized conditionally. This type of initialization is not possible at the time of declaration. This is where static constructor comes in picture. So if you compile and run this program your output would look similar to this :&lt;br /&gt;&lt;br /&gt;Static&lt;Class&gt; Constructor for Class Test1 Called..&lt;br /&gt;id = 20&lt;br /&gt;&lt;br /&gt;Since &lt;id&gt; in class Test was initialized with a value of 5, therefore &lt;id&gt; in class Test1 got initialized to a value of 20.&lt;br /&gt;&lt;br /&gt;Some important point regarding static constructor from C# Language Specification and C# Programmer's Reference :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1)&lt;/strong&gt; The static constructor for a class executes before any instance of the class is created.&lt;br /&gt;&lt;strong&gt;2)&lt;/strong&gt; The static constructor for a class executes before any of the static members for the class are referenced.&lt;br /&gt;&lt;strong&gt;3)&lt;/strong&gt; The static constructor for a class executes after the static field initializers (if any) for the class.&lt;br /&gt;&lt;strong&gt;4)&lt;/strong&gt; The static constructor for a class executes at most one time during a single program instantiation&lt;br /&gt;&lt;strong&gt;5)&lt;/strong&gt; A static constructor does not take access modifiers or have parameters.&lt;br /&gt;&lt;strong&gt;6)&lt;/strong&gt; A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced. &lt;br /&gt;&lt;strong&gt;7)&lt;/strong&gt; A static constructor cannot be called directly.&lt;br /&gt;&lt;strong&gt;8)&lt;/strong&gt; The user has no control on when the static constructor is executed in the program. &lt;br /&gt;&lt;strong&gt;9)&lt;/strong&gt; A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.&lt;br /&gt;&lt;br /&gt;Hopefully, this would clear the confusion some of developers have about static constructor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-5553082276258009688?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/5553082276258009688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/5553082276258009688'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/static-constructor.html' title='Static constructor'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-3354093403679303206</id><published>2008-11-14T10:41:00.001+05:30</published><updated>2008-11-14T10:42:48.581+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio IDE'/><title type='text'>How to Clear Recent Project list or File list from Visual Studio .Net Start Page</title><content type='html'>If you are an &lt;span style="font-weight:bold;"&gt;Advanced User&lt;/span&gt; who has priviledges to edit Registry here you go.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;STEPS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    Close Visual Studio (if its open)&lt;br /&gt;&lt;br /&gt;    Start &gt; Run &gt; RegEdit(Backup registry before making changes)&lt;br /&gt;&lt;br /&gt;    GOTO&lt;br /&gt;&lt;br /&gt;    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\&lt;version&gt;\ProjectMRUList&lt;br /&gt;&lt;br /&gt;    remove unnecessary items from list.&lt;br /&gt;&lt;br /&gt;    If needed reorder your list.  File1, File2 etc. Otherwise Visual Studio might not read them properly.&lt;br /&gt;&lt;br /&gt;    Similarly repeat the steps for FileMRuList&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-3354093403679303206?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/3354093403679303206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/3354093403679303206'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/how-to-clear-recent-project-list-or.html' title='How to Clear Recent Project list or File list from Visual Studio .Net Start Page'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-1667569605650150290</id><published>2008-11-14T10:37:00.002+05:30</published><updated>2008-11-14T10:43:42.781+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio IDE'/><title type='text'>What are refresh file (xxxx.refresh.dll)</title><content type='html'>Does anyone have a good resource on dlls and how they are used / generated in Visual Studio? A few questions I'm rather hazy on specifically are:&lt;br /&gt;&lt;br /&gt;    * How refresh files work&lt;br /&gt;    * How dll version numbers are generated&lt;br /&gt;    * The difference between adding a reference by project vs browsing for the &lt;br /&gt;specific dll&lt;br /&gt;&lt;br /&gt;The general term for a .NET DLL is an assembly. They are a single atomic unit of deployment and consist of one or more CLR 'modules' (for most developers usually just one unless they are combining compiler output from two or more languages for example). Assemblies contain both CIL code and CLR metadata such as the assembly manifest.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;.refresh Files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;.refresh files are simply text files that tell VS where to check for new builds of referenced dll's. They are used in file based web projects where there isn't a project file to store this info.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Version Numbers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;.NET Assembly version numbers are generated by an assembly scoped attribute AssemblyVersion which is usually found in a source file named 'AssemblyInfo.cs' (found under a project folder named 'Properties' from VS2005 onwards). Version numbers are comprised of major.minor.build.revision, for example -&lt;br /&gt;&lt;br /&gt;[assembly: AssemblyVersion("1.0.0.0")]&lt;br /&gt;&lt;br /&gt;AssemblyVersion is used as part of an assembly's identity (i.e. in its strong name) and plays an important role in the binding process and during version policy decisions.&lt;br /&gt;&lt;br /&gt;For example if I had two assemblies of the same name in the GAC then the AssemblyVersion attribute would differentiate them for the purposes of loading a specific version of the assembly.&lt;br /&gt;&lt;br /&gt;AssemblyVersion number can be fixed and incremented manually or you can allow the compiler to generate the build and revision numbers for you by specifying:&lt;br /&gt;&lt;br /&gt;[assembly: AssemblyVersion("1.0.*")] - generates build and revision number&lt;br /&gt;[assembly: AssemblyVersion("1.0.0.*")] - generates revision number&lt;br /&gt;&lt;br /&gt;If the AssemblyVersion attribute is not present then the version number default to '0.0.0.0'.&lt;br /&gt;&lt;br /&gt;The value of the AssemblyVersion attribute becomes part of an assembly's manifest, the AssemblyFileVersion attribute value does not.&lt;br /&gt;&lt;br /&gt;The AssemblyFileVersion attribute is used to embed a Win32 file version into the DLL. If this is not present then AssemblyVersion is used. It has no bearing on how the .NET assembly loader/resolver chooses which version of an assembly to load.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Project References vs Browsing For DLL&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you're adding a project reference it means that the referenced project will be part of your solution. This makes debugging simpler by being able to step directly into your referenced project's code. If you only add a dll reference then you don't have the benefits of the project being part of the solution and being able to step into the code within the solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-1667569605650150290?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://dotnetarmy.blogspot.com/2008/11/how-to-clear-recent-project-list-or.html' title='What are refresh file (xxxx.refresh.dll)'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1667569605650150290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1667569605650150290'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/what-are-refresh-file-xxxxrefreshdll.html' title='What are refresh file (xxxx.refresh.dll)'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-4134555501328839954</id><published>2008-11-07T10:53:00.003+05:30</published><updated>2008-11-07T11:01:04.823+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataBase'/><title type='text'>Static Vs Dynamic Queries</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Static&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;By static SQL we mean SQL code written once in the development phase when database and query structures are known. Static SQL is usually targeted at a specific database and in many cases gets stored in stored procedures. Many applications (especially Enterprise Applications) reach a stage where some dynamic data manipulation is required and static SQL techniques no longer suffice. Common examples are custom reports and filters designed by an application user. In order to support such functionality, an application must exhibit UI to define the report or filter, UI to display the results and an engine which is able to render SQL SELECT statement from the report definition. Here Sql.Net steps in to automate the process of SQL generation in a convenient, time saving, database independent way. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Dynamic&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Dynamic SQL generation is also needed in applications where the databases structure itself is dynamic. Many Enterprise Applications allow users to customize the way data is stored and displayed. This can involve columns being added or deleted or whole database tables dropped and created. Static SQL can not be written to work with dynamic structure because identifier names can not be substituted with variables. Therefore, SQL statements which manipulate or fetch data from non static storages must be created and rendered programmatically in runtime. Using Sql.Net for that purpose relieves your organization of the necessity to hand-code SQL renderers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some More Definitions&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Ist&lt;/span&gt; &lt;br /&gt;Static query will create an execution plan during compilation.&lt;br /&gt;Dynamic query will create execution plan at run time.&lt;br /&gt;It’s very slow in execution since building the plan at run time makes it too slow.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;2nd&lt;/span&gt;&lt;br /&gt;When your query pass with value (static) &lt;br /&gt;and when your query pass with parameter like (@user_name)&lt;br /&gt;is dynamic query.&lt;br /&gt;&lt;br /&gt;Static query&lt;br /&gt;select * from TblEmpDetail where user_name='Kapil'&lt;br /&gt;&lt;br /&gt;Dynamic query&lt;br /&gt;select * from TblEmpDetail Where user_name=@user_name&lt;br /&gt;where @user_name=sqlparameter&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-4134555501328839954?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://dotnetarmy.blogspot.com/2008/11/static-vs-dynamic-queries.html' title='Static Vs Dynamic Queries'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4134555501328839954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4134555501328839954'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/static-vs-dynamic-queries.html' title='Static Vs Dynamic Queries'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-7169472896020264659</id><published>2008-11-05T12:43:00.003+05:30</published><updated>2008-11-05T15:27:52.263+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>WebSite Performance Part-3</title><content type='html'>&lt;strong&gt;Preload Components&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;Preload may look like the opposite of post-load, but it actually has a different goal. By preloading components you can take advantage of the time the browser is idle and request components (like images, styles and scripts) you'll need in the future. This way when the user visits the next page, you could have most of the components already in the cache and your page will load much faster for the user. &lt;br /&gt;&lt;br /&gt;There are actually several types of preloading: &lt;br /&gt;&lt;br /&gt;Unconditional preload - as soon as onload fires, you go ahead and fetch some extra components. Check google.com for an example of how a sprite image is requested onload. This sprite image is not needed on the google.com homepage, but it is needed on the consecutive search result page. &lt;br /&gt;Conditional preload - based on a user action you make an educated guess where the user is headed next and preload accordingly. On search.yahoo.com you can see how some extra components are requested after you start typing in the input box. &lt;br /&gt;Anticipated preload - preload in advance before launching a redesign. It often happens after a redesign that you hear: "The new site is cool, but it's slower than before". Part of the problem could be that the users were visiting your old site with a full cache, but the new one is always an empty cache experience. You can mitigate this side effect by preloading some components before you even launched the redesign. Your old site can use the time the browser is idle and request images and scripts that will be used by the new site &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Reduce the Number of DOM Elements&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;A complex page means more bytes to download and it also means slower DOM access in JavaScript. It makes a difference if you loop through 500 or 5000 DOM elements on the page when you want to add an event handler for example. &lt;br /&gt;&lt;br /&gt;A high number of DOM elements can be a symptom that there's something that should be improved with the markup of the page without necessarily removing content. Are you using nested tables for layout purposes? Are you throwing in more div TAGS only to fix layout issues? Maybe there's a better and more semantically correct way to do your markup. &lt;br /&gt;&lt;br /&gt;A great help with layouts are the YUI CSS utilities: grids.css can help you with the overall layout, fonts.css and reset.css can help you strip away the browser's defaults formatting. This is a chance to start fresh and think about your markup, for example use div TAGS only when it makes sense semantically, and not because it renders a new line. &lt;br /&gt;&lt;br /&gt;The number of DOM elements is easy to test, just type in Firebug's console:&lt;br /&gt;document.getElementsByTagName('*').length &lt;br /&gt;&lt;br /&gt;And how many DOM elements are too many? Check other similar pages that have good markup. For example the Yahoo! Home Page is a pretty busy page and still under 700 elements (HTML tags). &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Split Components Across Domains&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;Splitting components allows you to maximize parallel downloads. Make sure you're using not more than 2-4 domains because of the DNS lookup penalty. For example, you can host your HTML and dynamic content on www.example.org and split static components between static1.example.org and static2.example.org &lt;br /&gt;&lt;br /&gt;For more information check "Maximizing Parallel Downloads in the Carpool Lane" by Tenni Theurer and Patty Chi. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Minimize the Number of iframes&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;Iframes allow an HTML document to be inserted in the parent document. It's important to understand how iframes work so they can be used effectively. &lt;br /&gt;&lt;br /&gt;iframe TAG pros: &lt;br /&gt;&lt;br /&gt;Helps with slow third-party content like badges and ads &lt;br /&gt;Security sandbox &lt;br /&gt;Download scripts in parallel &lt;br /&gt;iframe TAG cons: &lt;br /&gt;&lt;br /&gt;Costly even if blank &lt;br /&gt;Blocks page onload &lt;br /&gt;Non-semantic &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;No 404s&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;HTTP requests are expensive so making an HTTP request and getting a useless response (i.e. 404 Not Found) is totally unnecessary and will slow down the user experience without any benefit. &lt;br /&gt;&lt;br /&gt;Some sites have helpful 404s "Did you mean X?", which is great for the user experience but also wastes server resources (like database, etc). Particularly bad is when the link to an external JavaScript is wrong and the result is a 404. First, this download will block parallel downloads. Next the browser may try to parse the 404 response body as if it were JavaScript code, trying to find something usable in it. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Reduce Cookie Size&lt;/strong&gt;: cookie&lt;br /&gt;&lt;br /&gt;HTTP cookies are used for a variety of reasons such as authentication and personalization. Information about cookies is exchanged in the HTTP headers between web servers and browsers. It's important to keep the size of cookies as low as possible to minimize the impact on the user's response time. &lt;br /&gt;&lt;br /&gt;For more information check "When the Cookie Crumbles" by Tenni Theurer and Patty Chi. The take-home of this research: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Eliminate unnecessary cookies &lt;br /&gt;Keep cookie sizes as low as possible to minimize the impact on the user response time &lt;br /&gt;Be mindful of setting cookies at the appropriate domain level so other sub-domains are not affected &lt;br /&gt;Set an Expires date appropriately. An earlier Expires date or none removes the cookie sooner, improving the user response time &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Use Cookie-free Domains for Components&lt;/strong&gt;: cookie&lt;br /&gt;&lt;br /&gt;When the browser makes a request for a static image and sends cookies together with the request, the server doesn't have any use for those cookies. So they only create network traffic for no good reason. You should make sure static components are requested with cookie-free requests. Create a subdomain and host all your static components there. &lt;br /&gt;&lt;br /&gt;If your domain is www.example.org, you can host your static components on static.example.org. However, if you've already set cookies on the top-level domain example.org as opposed to www.example.org, then all the requests to static.example.org will include those cookies. In this case, you can buy a whole new domain, host your static components there, and keep this domain cookie-free. Yahoo! uses yimg.com, YouTube uses ytimg.com, Amazon uses images-amazon.com and so on. &lt;br /&gt;&lt;br /&gt;Another benefit of hosting static components on a cookie-free domain is that some proxies might refuse to cache the components that are requested with cookies. On a related note, if you wonder if you should use example.org or www.example.org for your home page, consider the cookie impact. Omitting www leaves you no choice but to write cookies to *.example.org, so for performance reasons it's best to use the www subdomain and write the cookies to that subdomain. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;strong&gt;Minimize DOM Access&lt;/strong&gt;&lt;/strong&gt;: javascript&lt;br /&gt;&lt;br /&gt;Accessing DOM elements with JavaScript is slow so in order to have a more responsive page, you should: &lt;br /&gt;&lt;br /&gt;Cache references to accessed elements &lt;br /&gt;Update nodes "offline" and then add them to the tree &lt;br /&gt;Avoid fixing layout with JavaScript &lt;br /&gt;For more information check the YUI theatre's "High Performance Ajax Applications" by Julien Lecomte. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Develop Smart Event Handlers&lt;/strong&gt;: JavaScript&lt;br /&gt;&lt;br /&gt;Sometimes pages feel less responsive because of too many event handlers attached to different elements of the DOM tree which are then executed too often. That's why using event delegation is a good approach. If you have 10 buttons inside a div, attach only one event handler to the div wrapper, instead of one handler for each button. Events bubble up so you'll be able to catch the event and figure out which button it originated from. &lt;br /&gt;&lt;br /&gt;You also don't need to wait for the onload event in order to start doing something with the DOM tree. Often all you need is the element you want to access to be available in the tree. You don't have to wait for all images to be downloaded. DOMContentLoaded is the event you might consider using instead of onload, but until it's available in all browsers, you can use the YUI Event utility, which has an onAvailable method. &lt;br /&gt;&lt;br /&gt;For more information check the YUI theatre's "High Performance Ajax Applications" by Julien Lecomte. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Choose link tag over @import&lt;/strong&gt;: css&lt;br /&gt;&lt;br /&gt;One of the previous best practices states that CSS should be at the top in order to allow for progressive rendering. &lt;br /&gt;&lt;br /&gt;In IE @import behaves the same as using link TAG at the bottom of the page, so it's best not to use it. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Avoid Filters&lt;/strong&gt;: css&lt;br /&gt;&lt;br /&gt;The IE-proprietary AlphaImageLoader filter aims to fix a problem with semi-transparent true color PNGs in IE versions &lt; 7. The problem with this filter is that it blocks rendering and freezes the browser while the image is being downloaded. It also increases memory consumption and is applied per element, not per image, so the problem is multiplied. &lt;br /&gt;&lt;br /&gt;The best approach is to avoid AlphaImageLoader completely and use gracefully degrading PNG8 instead, which are fine in IE. If you absolutely need AlphaImageLoader, use the underscore hack _filter as to not penalize your IE7+ users. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Optimize Images&lt;/strong&gt;: images&lt;br /&gt;&lt;br /&gt;After a designer is done with creating the images for your web page, there are still some things you can try before you FTP those images to your web server. &lt;br /&gt;&lt;br /&gt;You can check the GIFs and see if they are using a palette size corresponding to the number of colors in the image. Using imagemagick it's easy to check using &lt;br /&gt;identify -verbose image.gif &lt;br /&gt;When you see an image useing 4 colors and a 256 color "slots" in the palette, there is room for improvement. &lt;br /&gt;Try converting GIFs to PNGs and see if there is a saving. More often than not, there is. Developers often hesitate to use PNGs due to the limited support in browsers, but this is now a thing of the past. The only real problem is alpha-transparency in true color PNGs, but then again, GIFs are not true color and don't support variable transparency either. So anything a GIF can do, a palette PNG (PNG8) can do too (except for animations). This simple imagemagick command results in totally safe-to-use PNGs:&lt;br /&gt;convert image.gif image.png &lt;br /&gt;"All we are saying is: Give PiNG a Chance!" &lt;br /&gt;Run pngcrush (or any other PNG optimizer tool) on all your PNGs. Example: &lt;br /&gt;pngcrush image.png -rem alla -reduce -brute result.png &lt;br /&gt;Run jpegtran on all your JPEGs. This tool does lossless JPEG operations such as rotation and can also be used to optimize and remove comments and other useless information (such as EXIF information) from your images. &lt;br /&gt;jpegtran -copy none -optimize -perfect src.jpg dest.jpg &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Optimize CSS Sprites &lt;/strong&gt;: images&lt;br /&gt;&lt;br /&gt;Arranging the images in the sprite horizontally as opposed to vertically usually results in a smaller file size. &lt;br /&gt;Combining similar colors in a sprite helps you keep the color count low, ideally under 256 colors so to fit in a PNG8. &lt;br /&gt;"Be mobile-friendly" and don't leave big gaps between the images in a sprite. This doesn't affect the file size as much but requires less memory for the user agent to decompress the image into a pixel map. 100x100 image is 10 thousand pixels, where 1000x1000 is 1 million pixels &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Don't Scale Images in HTML&lt;/strong&gt;: images&lt;br /&gt;&lt;br /&gt;Don't use a bigger image than you need just because you can set the width and height in HTML. If you need &lt;br /&gt;&lt;img width="100" height="100" src="mycat.jpg" alt="My Cat" /&gt; &lt;br /&gt;then your image (mycat.jpg) should be 100x100px rather than a scaled down 500x500px image. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Make favicon.ico Small and Cacheable&lt;/strong&gt;: images&lt;br /&gt;&lt;br /&gt;The favicon.ico is an image that stays in the root of your server. It's a necessary evil because even if you don't care about it the browser will still request it, so it's better not to respond with a 404 Not Found. Also since it's on the same server, cookies are sent every time it's requested. This image also interferes with the download sequence, for example in IE when you request extra components in the onload, the favicon will be downloaded before these extra components. &lt;br /&gt;&lt;br /&gt;So to mitigate the drawbacks of having a favicon.ico make sure: &lt;br /&gt;&lt;br /&gt;It's small, preferably under 1K. &lt;br /&gt;Set Expires header with what you feel comfortable (since you cannot rename it if you decide to change it). You can probably safely set the Expires header a few months in the future. You can check the last modified date of your current favicon.ico to make an informed decision. &lt;br /&gt;Imagemagick can help you create small favicons &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Keep Components under 25K&lt;/strong&gt;: mobile&lt;br /&gt;&lt;br /&gt;This restriction is related to the fact that iPhone won't cache components bigger than 25K. Note that this is the uncompressed size. This is where minification is important because gzip alone may not be sufficient. &lt;br /&gt;&lt;br /&gt;For more information check "Performance Research, Part 5: iPhone Cacheability - Making it Stick" by Wayne Shea and Tenni Theurer. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Pack Components into a Multipart Document&lt;/strong&gt;: mobile&lt;br /&gt;Packing components into a multipart document is like an email with attachments, it helps you fetch several components with one HTTP request (remember: HTTP requests are expensive). When you use this technique, first check if the user agent supports it (iPhone does not).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-7169472896020264659?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/7169472896020264659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/7169472896020264659'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/website-performance-part-3.html' title='WebSite Performance Part-3'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-7558848777756950633</id><published>2008-11-05T12:41:00.002+05:30</published><updated>2008-11-05T15:26:57.056+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Web Site performance part -2</title><content type='html'>&lt;strong&gt;Make JavaScript and CSS External&lt;/strong&gt;: JavaScript, css&lt;br /&gt;&lt;br /&gt;Many of these performance rules deal with how external components are managed. However, before these considerations arise you should ask a more basic question: Should JavaScript and CSS be contained in external files, or inlined in the page itself?&lt;br /&gt;&lt;br /&gt;Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests. &lt;br /&gt;&lt;br /&gt;The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files. &lt;br /&gt;&lt;br /&gt;Many web sites fall in the middle of these metrics. For these sites, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception where inlining is preferable is with home pages, such as Yahoo!'s front page and My Yahoo!. Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times.&lt;br /&gt;&lt;br /&gt;For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser's cache.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Reduce DNS Lookups&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;The Domain Name System (DNS) maps hostnames to IP addresses, just as phonebooks map people's names to their phone numbers. When you type www.yahoo.com into your browser, a DNS resolver contacted by the browser returns that server's IP address. DNS has a cost. It typically takes 20-120 milliseconds for DNS to lookup the IP address for a given hostname. The browser can't download anything from this hostname until the DNS lookup is completed. &lt;br /&gt;&lt;br /&gt;DNS lookups are cached for better performance. This caching can occur on a special caching server, maintained by the user's ISP or local area network, but there is also caching that occurs on the individual user's computer. The DNS information remains in the operating system's DNS cache (the "DNS Client service" on Microsoft Windows). Most browsers have their own caches, separate from the operating system's cache. As long as the browser keeps a DNS record in its own cache, it doesn't bother the operating system with a request for the record.&lt;br /&gt;&lt;br /&gt;Internet Explorer caches DNS lookups for 30 minutes by default, as specified by the DnsCacheTimeout registry setting. Firefox caches DNS lookups for 1 minute, controlled by the network.dnsCacheExpiration configuration setting. (Fasterfox changes this to 1 hour.)&lt;br /&gt;&lt;br /&gt;When the client's DNS cache is empty (for both the browser and the operating system), the number of DNS lookups is equal to the number of unique hostnames in the web page. This includes the hostnames used in the page's URL, images, script files, stylesheets, Flash objects, etc. Reducing the number of unique hostnames reduces the number of DNS lookups. &lt;br /&gt;&lt;br /&gt;Reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading that takes place in the page. Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times. My guideline is to split these components across at least two but no more than four hostnames. This results in a good compromise between reducing DNS lookups and allowing a high degree of parallel downloads.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Minify JavaScript and CSS&lt;/strong&gt;: javascript, css&lt;br /&gt;&lt;br /&gt;Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are JSMin and YUI Compressor. The YUI compressor can also minify CSS.&lt;br /&gt;&lt;br /&gt;Obfuscation is an alternative optimization that can be applied to source code. It's more complex than minification and thus more likely to generate bugs as a result of the obfuscation step itself. In a survey of ten top U.S. web sites, minification achieved a 21% size reduction versus 25% for obfuscation. Although obfuscation has a higher size reduction, minifying JavaScript is less risky.&lt;br /&gt;&lt;br /&gt;In addition to minifying external scripts and styles, inlined script TAG and style TAG blocks can and should also be minified. Even if you gzip your scripts and styles, minifying them will still reduce the size by 5% or more. As the use and size of JavaScript and CSS increases, so will the savings gained by minifying your code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Avoid Redirects&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;Redirects are accomplished using the 301 and 302 status codes. Here's an example of the HTTP headers in a 301 response:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      HTTP/1.1 301 Moved Permanently&lt;br /&gt;      Location: http://example.com/newuri&lt;br /&gt;      Content-Type: text/html&lt;br /&gt;The browser automatically takes the user to the URL specified in the Location field. All the information necessary for a redirect is in the headers. The body of the response is typically empty. Despite their names, neither a 301 nor a 302 response is cached in practice unless additional headers, such as Expires or Cache-Control, indicate it should be. The meta refresh tag and JavaScript are other ways to direct users to a different URL, but if you must do a redirect, the preferred technique is to use the standard 3xx HTTP status codes, primarily to ensure the back button works correctly.&lt;br /&gt;&lt;br /&gt;The main thing to remember is that redirects slow down the user experience. Inserting a redirect between the user and the HTML document delays everything in the page since nothing in the page can be rendered and no components can start being downloaded until the HTML document has arrived.&lt;br /&gt;&lt;br /&gt;One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to http://astrology.yahoo.com/astrology results in a 301 response containing a redirect to http://astrology.yahoo.com/astrology/ (notice the added trailing slash). This is fixed in Apache by using Alias or mod_rewrite, or the DirectorySlash directive if you're using Apache handlers.&lt;br /&gt;&lt;br /&gt;Connecting an old web site to a new one is another common use for redirects. Others include connecting different parts of a website and directing the user based on certain conditions (type of browser, type of user account, etc.). Using a redirect to connect two web sites is simple and requires little additional coding. Although using redirects in these situations reduces the complexity for developers, it degrades the user experience. Alternatives for this use of redirects include using Alias and mod_rewrite if the two code paths are hosted on the same server. If a domain name change is the cause of using redirects, an alternative is to create a CNAME (a DNS record that creates an alias pointing from one domain name to another) in combination with Alias or mod_rewrite.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Remove Duplicate Scripts&lt;/strong&gt;: JavaScript&lt;br /&gt;&lt;br /&gt;It hurts performance to include the same JavaScript file twice in one page. This isn't as unusual as you might think. A review of the ten top U.S. web sites shows that two of them contain a duplicated script. Two main factors increase the odds of a script being duplicated in a single web page: team size and number of scripts. When it does happen, duplicate scripts hurt performance by creating unnecessary HTTP requests and wasted JavaScript execution.&lt;br /&gt;&lt;br /&gt;Unnecessary HTTP requests happen in Internet Explorer, but not in Firefox. In Internet Explorer, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page.&lt;br /&gt;&lt;br /&gt;In addition to generating wasteful HTTP requests, time is wasted evaluating the script multiple times. This redundant JavaScript execution happens in both Firefox and Internet Explorer, regardless of whether the script is cacheable.&lt;br /&gt;&lt;br /&gt;One way to avoid accidentally including the same script twice is to implement a script management module in your templating system. The typical way to include a script is to use the SCRIPT tag in your HTML page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;script type="text/javascript" src="menu_1.0.17.js"&gt;&lt;/script&gt;An alternative in PHP would be to create a function called insertScript.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;?php insertScript("menu.js") ?&gt;In addition to preventing the same script from being inserted multiple times, this function could handle other issues with scripts, such as dependency checking and adding version numbers to script filenames to support far future Expires headers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Configure ETags&lt;/strong&gt;: server&lt;br /&gt;&lt;br /&gt;Entity tags (ETags) are a mechanism that web servers and browsers use to determine whether the component in the browser's cache matches the one on the origin server. (An "entity" is another word a "component": images, scripts, stylesheets, etc.) ETags were added to provide a mechanism for validating entities that is more flexible than the last-modified date. An ETag is a string that uniquely identifies a specific version of a component. The only format constraints are that the string be quoted. The origin server specifies the component's ETag using the ETag response header.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      HTTP/1.1 200 OK&lt;br /&gt;      Last-Modified: Tue, 12 Dec 2006 03:03:59 GMT&lt;br /&gt;      ETag: "10c24bc-4ab-457e1c1f"&lt;br /&gt;      Content-Length: 12195&lt;br /&gt;Later, if the browser has to validate a component, it uses the If-None-Match header to pass the ETag back to the origin server. If the ETags match, a 304 status code is returned reducing the response by 12195 bytes for this example. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      GET /i/yahoo.gif HTTP/1.1&lt;br /&gt;      Host: us.yimg.com&lt;br /&gt;      If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT&lt;br /&gt;      If-None-Match: "10c24bc-4ab-457e1c1f"&lt;br /&gt;      HTTP/1.1 304 Not Modified&lt;br /&gt;The problem with ETags is that they typically are constructed using attributes that make them unique to a specific server hosting a site. ETags won't match when a browser gets the original component from one server and later tries to validate that component on a different server, a situation that is all too common on Web sites that use a cluster of servers to handle requests. By default, both Apache and IIS embed data in the ETag that dramatically reduces the odds of the validity test succeeding on web sites with multiple servers. &lt;br /&gt;&lt;br /&gt;The ETag format for Apache 1.3 and 2.x is inode-size-timestamp. Although a given file may reside in the same directory across multiple servers, and have the same file size, permissions, timestamp, etc., its inode is different from one server to the next.  &lt;br /&gt;&lt;br /&gt;IIS 5.0 and 6.0 have a similar issue with ETags. The format for ETags on IIS is Filetimestamp:ChangeNumber. A ChangeNumber is a counter used to track configuration changes to IIS. It's unlikely that the ChangeNumber is the same across all IIS servers behind a web site. &lt;br /&gt;&lt;br /&gt;The end result is ETags generated by Apache and IIS for the exact same component won't match from one server to another. If the ETags don't match, the user doesn't receive the small, fast 304 response that ETags were designed for; instead, they'll get a normal 200 response along with all the data for the component. If you host your web site on just one server, this isn't a problem. But if you have multiple servers hosting your web site, and you're using Apache or IIS with the default ETag configuration, your users are getting slower pages, your servers have a higher load, you're consuming greater bandwidth, and proxies aren't caching your content efficiently. Even if your components have a far future Expires header, a conditional GET request is still made whenever the user hits Reload or Refresh. &lt;br /&gt;&lt;br /&gt;If you're not taking advantage of the flexible validation model that ETags provide, it's better to just remove the ETag altogether. The Last-Modified header validates based on the component's timestamp. And removing the ETag reduces the size of the HTTP headers in both the response and subsequent requests. This Microsoft Support article describes how to remove ETags. In Apache, this is done by simply adding the following line to your Apache configuration file: &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Make Ajax Cacheable&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;One of the cited benefits of Ajax is that it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using Ajax is no guarantee that the user won't be twiddling his thumbs waiting for those asynchronous JavaScript and XML responses to return. In many applications, whether or not the user is kept waiting depends on how Ajax is used. For example, in a web-based email client the user will be kept waiting for the results of an Ajax request to find all the email messages that match their search criteria. It's important to remember that "asynchronous" does not imply "instantaneous".&lt;br /&gt;&lt;br /&gt;To improve performance, it's important to optimize these Ajax responses. The most important way to improve the performance of Ajax is to make the responses cacheable, as discussed in Add an Expires or a Cache-Control Header. Some of the other rules also apply to Ajax:&lt;br /&gt;&lt;br /&gt;Gzip Components&lt;br /&gt;&lt;br /&gt;Reduce DNS Lookups&lt;br /&gt;&lt;br /&gt;Minify JavaScript&lt;br /&gt;&lt;br /&gt;Avoid Redirects&lt;br /&gt;&lt;br /&gt;Configure ETags&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let's look at an example. A Web 2.0 email client might use Ajax to download the user's address book for autocompletion. If the user hasn't modified her address book since the last time she used the email web app, the previous address book response could be read from cache if that Ajax response was made cacheable with a future Expires or Cache-Control header. The browser must be informed when to use a previously cached address book response versus requesting a new one. This could be done by adding a timestamp to the address book Ajax URL indicating the last time the user modified her address book, for example, &amp;t=1190241612. If the address book hasn't been modified since the last download, the timestamp will be the same and the address book will be read from the browser's cache eliminating an extra HTTP roundtrip. If the user has modified her address book, the timestamp ensures the new URL doesn't match the cached response, and the browser will request the updated address book entries.&lt;br /&gt;&lt;br /&gt;Even though your Ajax responses are created dynamically, and might only be applicable to a single user, they can still be cached. Doing so will make your Web 2.0 apps faster.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;strong&gt;Flush the Buffer Early&lt;/strong&gt;&lt;/strong&gt;: server&lt;br /&gt;&lt;br /&gt;When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function flush(). It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends. &lt;br /&gt;&lt;br /&gt;A good place to consider flushing is right after the HEAD because the HTML for the head is usually easier to produce and it allows you to include any CSS and JavaScript files for the browser to start fetching in parallel while the backend is still processing. &lt;br /&gt;&lt;br /&gt;Yahoo! search pioneered research and real user testing to prove the benefits of using this technique.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Use GET for AJAX Requests&lt;/strong&gt;: server&lt;br /&gt;&lt;br /&gt;The Yahoo! Mail team found that when using XMLHttpRequest, POST is implemented in the browsers as a two-step process: sending the headers first, then sending data. So it's best to use GET, which only takes one TCP packet to send (unless you have a lot of cookies). The maximum URL length in IE is 2K, so if you send more than 2K data you might not be able to use GET. &lt;br /&gt;&lt;br /&gt;An interesting side affect is that POST without actually posting any data behaves like GET. Based on the HTTP specs, GET is meant for retrieving information, so it makes sense (semantically) to use GET when you're only requesting data, as opposed to sending data to be stored server-side. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Post-load Components&lt;/strong&gt;: content&lt;br /&gt;&lt;br /&gt;You can take a closer look at your page and ask yourself: "What's absolutely required in order to render the page initially?". The rest of the content and components can wait. &lt;br /&gt;&lt;br /&gt;JavaScript is an ideal candidate for splitting before and after the onload event. For example if you have JavaScript code and libraries that do drag and drop and animations, those can wait, because dragging elements on the page comes after the initial rendering. Other places to look for candidates for post-loading include hidden content (content that appears after a user action) and images below the fold. &lt;br /&gt;&lt;br /&gt;Tools to help you out in your effort: YUI Image Loader allows you to delay images below the fold and the YUI Get utility is an easy way to include JS and CSS on the fly. For an example in the wild take a look at Yahoo! Home Page with Firebug's Net Panel turned on. &lt;br /&gt;&lt;br /&gt;It's good when the performance goals are inline with other web development best practices. In this case, the idea of progressive enhancement tells us that JavaScript, when supported, can improve the user experience but you have to make sure the page works even without JavaScript. So after you've made sure the page works fine, you can enhance it with some post-loaded scripts that give you more bells and whistles such as drag and drop and animations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-7558848777756950633?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/7558848777756950633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/7558848777756950633'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/web-site-performance-part-2.html' title='Web Site performance part -2'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-4743603616992011546</id><published>2008-11-05T12:36:00.003+05:30</published><updated>2008-11-05T15:27:38.822+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>WebSite Performance -- Part Ist</title><content type='html'>&lt;strong&gt;Best Practices for Speeding Up Your Web Site PART - IST&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I and My team have identified a number of best practices for making web pages fast. The list includes 34 best practices divided into 7 categories.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Filter by category&lt;/strong&gt;&lt;br /&gt;1. Content &lt;br /&gt;2. Server &lt;br /&gt;3. Cookie &lt;br /&gt;4. CSS &lt;br /&gt;5. JavaScript &lt;br /&gt;6. Images &lt;br /&gt;7. Mobile &lt;br /&gt;8. All &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Minimize HTTP Requests&lt;/strong&gt; - Content&lt;br /&gt;&lt;br /&gt;80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, style sheets, scripts, flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. &lt;br /&gt;&lt;br /&gt;One way to reduce the number of components in the page is to simplify the page's design. But is there a way to build pages with richer content while also achieving fast response times? Here are some techniques for reducing the number of HTTP requests, while still supporting rich page designs.&lt;br /&gt;&lt;br /&gt;Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single style sheet. Combining files is more challenging when the scripts and style sheets vary from page to page, but making this part of your release process improves response times.&lt;br /&gt;&lt;br /&gt;CSS Sprites are the preferred method for reducing the number of image requests. Combine your background images into a single image and use the CSS background-image and background-position properties to display the desired image segment.&lt;br /&gt;&lt;br /&gt;Image maps combine multiple images into a single image. The overall size is about the same, but reducing the number of HTTP requests speeds up the page. Image maps only work if the images are contiguous in the page, such as a navigation bar. Defining the coordinates of image maps can be tedious and error prone. Using image maps for navigation is not accessible too, so it's not recommended.&lt;br /&gt;&lt;br /&gt;Inline images use the data: URL scheme to embed the image data in the actual page. This can increase the size of your HTML document. Combining inline images into your (cached) stylesheets is a way to reduce HTTP requests and avoid increasing the size of your pages. Inline images are not yet supported across all major browsers.&lt;br /&gt;&lt;br /&gt;Reducing the number of HTTP requests in your page is the place to start. This is the most important guideline for improving performance for first time visitors. As described in Tenni Theurer's blog post Browser Cache Usage - Exposed!, 40-60% of daily visitors to your site come in with an empty cache. Making your page fast for these first time visitors is key to a better user experience.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Use a Content Delivery Network&lt;/strong&gt; - Server&lt;br /&gt;&lt;br /&gt;The user's proximity to your web server has an impact on response times. Deploying your content across multiple, geographically dispersed servers will make your pages load faster from the user's perspective. But where should you start?&lt;br /&gt;&lt;br /&gt;As a first step to implementing geographically dispersed content, don't attempt to redesign your web application to work in a distributed architecture. Depending on the application, changing the architecture could include daunting tasks such as synchronizing session state and replicating database transactions across server locations. Attempts to reduce the distance between users and your content could be delayed by, or never pass, this application architecture step. &lt;br /&gt;&lt;br /&gt;Remember that 80-90% of the end-user response time is spent downloading all the components in the page: images, stylesheets, scripts, Flash, etc. This is the Performance Golden Rule. Rather than starting with the difficult task of redesigning your application architecture, it's better to first disperse your static content. This not only achieves a bigger reduction in response times, but it's easier thanks to content delivery networks.&lt;br /&gt;&lt;br /&gt;A content delivery network (CDN) is a collection of web servers distributed across multiple locations to deliver content more efficiently to users. The server selected for delivering content to a specific user is typically based on a measure of network proximity. For example, the server with the fewest network hops or the server with the quickest response time is chosen.&lt;br /&gt;&lt;br /&gt;Some large Internet companies own their own CDN, but it's cost-effective to use a CDN service provider, such as Akamai Technologies, Mirror Image Internet, or Limelight Networks. For start-up companies and private web sites, the cost of a CDN service can be prohibitive, but as your target audience grows larger and becomes more global, a CDN is necessary to achieve fast response times. At Yahoo!, properties that moved static content off their application web servers to a CDN improved end-user response times by 20% or more. Switching to a CDN is a relatively easy code change that will dramatically improve the speed of your web site.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Add an Expires or a Cache-Control Header&lt;/strong&gt;: Server&lt;br /&gt;&lt;br /&gt;There are two things in this rule:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;For static components&lt;/strong&gt; - &lt;em&gt;implement "Never expire" policy by setting far future Expires header &lt;/em&gt;&lt;br /&gt;&lt;strong&gt;For dynamic components&lt;/strong&gt; - &lt;em&gt;use an appropriate Cache-Control header to help the browser with conditional requests &lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Web page designs are getting richer and richer, which means more scripts, stylesheets, images, and Flash in the page. A first-time visitor to your page may have to make several HTTP requests, but by using the Expires header you make those components cacheable. This avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often used with images, but they should be used on all components including scripts, stylesheets, and Flash components.&lt;br /&gt;&lt;br /&gt;Browsers (and proxies) use a cache to reduce the number and size of HTTP requests, making web pages load faster. A web server uses the Expires header in the HTTP response to tell the client how long a component can be cached. This is a far future Expires header, telling the browser that this response won't be stale until April 15, 2010. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      Expires: Thu, 15 Apr 2010 20:00:00 GMT&lt;br /&gt;If your server is Apache, use the ExpiresDefault directive to set an expiration date relative to the current date. This example of the ExpiresDefault directive sets the Expires date 10 years out from the time of the request.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      ExpiresDefault "access plus 10 years"&lt;br /&gt;Keep in mind, if you use a far future Expires header you have to change the component's filename whenever the component changes. At Yahoo! we often make this step part of the build process: a version number is embedded in the component's filename, for example, yahoo_2.0.6.js.&lt;br /&gt;&lt;br /&gt;Using a far future Expires header affects page views only after a user has already visited your site. It has no effect on the number of HTTP requests when a user visits your site for the first time and the browser's cache is empty. Therefore the impact of this performance improvement depends on how often users hit your pages with a primed cache. (A "primed cache" already contains all of the components in the page.) We measured this at Yahoo! and found the number of page views with a primed cache is 75-85%. By using a far future Expires header, you increase the number of components that are cached by the browser and re-used on subsequent page views without sending a single byte over the user's Internet connection.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Gzip Components&lt;/strong&gt; - server&lt;br /&gt;&lt;br /&gt;The time it takes to transfer an HTTP request and response across the network can be significantly reduced by decisions made by front-end engineers. It's true that the end-user's bandwidth speed, Internet service provider, proximity to peering exchange points, etc. are beyond the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of the HTTP response.&lt;br /&gt;&lt;br /&gt;Starting with HTTP/1.1, web clients indicate support for compression with the Accept-Encoding header in the HTTP request.&lt;br /&gt;&lt;br /&gt;      Accept-Encoding: gzip, deflate If the web server sees this header in the request, it may compress the response using one of the methods listed by the client. The web server notifies the web client of this via the Content-Encoding header in the response.&lt;br /&gt;&lt;br /&gt;      Content-Encoding: gzipGzip is the most popular and effective compression method at this time. It was developed by the GNU project and standardized by RFC 1952. The only other compression format you're likely to see is deflate, but it's less effective and less popular. &lt;br /&gt;&lt;br /&gt;Gzipping generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip. If you use Apache, the module configuring gzip depends on your version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate. &lt;br /&gt;&lt;br /&gt;There are known issues with browsers and proxies that may cause a mismatch in what the browser expects and what it receives with regard to compressed content. Fortunately, these edge cases are dwindling as the use of older browsers drops off. The Apache modules help out by adding appropriate Vary response headers automatically. &lt;br /&gt;&lt;br /&gt;Servers choose what to gzip based on file type, but are typically too limited in what they decide to compress. Most web sites gzip their HTML documents. It's also worthwhile to gzip your scripts and style sheets, but many web sites miss this opportunity. In fact, it's worthwhile to compress any text response including XML and JSON. Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes. &lt;br /&gt;&lt;br /&gt;Gzipping as many file types as possible is an easy way to reduce page weight and accelerate the user experience.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Put Style sheets at the Top&lt;/strong&gt;: css&lt;br /&gt;&lt;br /&gt;While researching performance at Yahoo!, we discovered that moving style sheets to the document HEAD makes pages appear to be loading faster. This is because putting style sheets in the HEAD allows the page to render progressively. &lt;br /&gt;&lt;br /&gt;Front-end engineers that care about performance want a page to load progressively; that is, we want the browser to display whatever content it has as soon as possible. This is especially important for pages with a lot of content and for users on slower Internet connections. The importance of giving users visual feedback, such as progress indicators, has been well researched and documented. In our case the HTML page is the progress indicator! When the browser loads the page progressively the header, the navigation bar, the logo at the top, etc. all serve as visual feedback for the user who is waiting for the page. This improves the overall user experience.&lt;br /&gt;&lt;br /&gt;The problem with putting style sheets near the bottom of the document is that it prohibits progressive rendering in many browsers, including Internet Explorer. These browsers block rendering to avoid having to redraw elements of the page if their styles change. The user is stuck viewing a blank white page. &lt;br /&gt;&lt;br /&gt;The HTML specification clearly states that stylesheets are to be included in the HEAD of the page: "Unlike A, [LINK] may only appear in the HEAD section of a document, although it may appear any number of times." Neither of the alternatives, the blank white screen or flash of unstyled content, are worth the risk. The optimal solution is to follow the HTML specification and load your stylesheets in the document HEAD.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Put Scripts at the Bottom&lt;/strong&gt;: javascript&lt;br /&gt;&lt;br /&gt;The problem caused by scripts is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames. &lt;br /&gt;&lt;br /&gt;In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document. write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations.&lt;br /&gt;&lt;br /&gt;An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Avoid CSS Expressions&lt;/strong&gt;: css&lt;br /&gt;&lt;br /&gt;CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They're supported in Internet Explorer, starting with version 5. As an example, the background color could be set to alternate every hour using CSS expressions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );&lt;br /&gt;As shown here, the expression method accepts a JavaScript expression. The CSS property is set to the result of evaluating the JavaScript expression. The expression method is ignored by other browsers, so it is useful for setting properties in Internet Explorer needed to create a consistent experience across browsers.&lt;br /&gt;&lt;br /&gt;The problem with expressions is that they are evaluated more frequently than most people expect. Not only are they evaluated when the page is rendered and resized, but also when the page is scrolled and even when the user moves the mouse over the page. Adding a counter to the CSS expression allows us to keep track of when and how often a CSS expression is evaluated. Moving the mouse around the page can easily generate more than 10,000 evaluations.&lt;br /&gt;&lt;br /&gt;One way to reduce the number of times your CSS expression is evaluated is to use one-time expressions, where the first time the expression is evaluated it sets the style property to an explicit value, which replaces the CSS expression. If the style property must be set dynamically throughout the life of the page, using event handlers instead of CSS expressions is an alternative approach. If you must use CSS expressions, remember that they may be evaluated thousands of times and could affect the performance of your page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-4743603616992011546?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4743603616992011546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4743603616992011546'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/website-performance-part-ist.html' title='WebSite Performance -- Part Ist'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-6767943512160513016</id><published>2008-11-05T11:52:00.002+05:30</published><updated>2008-11-05T11:56:50.318+05:30</updated><title type='text'>Wesite performance Tips</title><content type='html'>&lt;div class=Section1&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal align=center style='text-align:center'&gt;&lt;b style='mso-bidi-font-weight:&lt;br /&gt;normal'&gt;&lt;u&gt;Best Practices for Speeding &lt;span class=GramE&gt;Up&lt;/span&gt; Your Web&lt;br /&gt;Site&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;I and My team have identified a number of best practices for&lt;br /&gt;making web pages fast. The list includes 34 best practices divided into 7&lt;br /&gt;categories.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;Filter by category:&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol style='margin-top:0in' start=1 type=1&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;Content&lt;br /&gt;     &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;Server&lt;br /&gt;     &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;Cookie&lt;br /&gt;     &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;CSS &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;JavaScript&lt;br /&gt;     &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;Images&lt;br /&gt;     &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;&lt;st1:City&lt;br /&gt;     w:st="on"&gt;&lt;st1:place w:st="on"&gt;Mobile&lt;/st1:place&gt;&lt;/st1:City&gt; &lt;/li&gt;&lt;br /&gt; &lt;li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'&gt;All &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Minimize HTTP&lt;br /&gt;Requests&lt;/u&gt;:&lt;/b&gt; Content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;80% of the end-user response time is spent on the front-end.&lt;br /&gt;Most of this time is tied up in downloading all the components in the page:&lt;br /&gt;images, style sheets, scripts, flash, etc. Reducing the number of components in&lt;br /&gt;turn reduces the number of HTTP requests required to render the page. This is&lt;br /&gt;the key to faster pages. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One way to reduce the number of components in the page is to&lt;br /&gt;simplify the page's design. But is there a way to build pages with richer content&lt;br /&gt;while also achieving fast response times? Here are some techniques for reducing&lt;br /&gt;the number of HTTP requests, while still supporting rich page designs.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Combined files are a way to reduce the number of HTTP&lt;br /&gt;requests by combining all scripts into a single script, and similarly combining&lt;br /&gt;all CSS into a single style sheet. Combining files is more challenging when the&lt;br /&gt;scripts and style sheets vary from page to page, but making this part of your&lt;br /&gt;release process improves response times.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;CSS Sprites are the preferred method for reducing the number&lt;br /&gt;of image requests. Combine your background images into a single image and use&lt;br /&gt;the CSS background-image and background-position properties to display the&lt;br /&gt;desired image segment.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;i style='mso-bidi-font-style:normal'&gt;&lt;u&gt;Image maps combine&lt;br /&gt;multiple images into a single image. The overall size is about the same, but&lt;br /&gt;reducing the number of HTTP requests speeds up the page. Image maps only work&lt;br /&gt;if the images are contiguous in the page, such as a navigation bar. Defining&lt;br /&gt;the coordinates of image maps can be tedious and error prone. Using image maps&lt;br /&gt;for navigation is not accessible too, so it's not recommended.&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Inline images use the data: URL scheme to embed the image&lt;br /&gt;data in the actual page. This can increase the size of your HTML document.&lt;br /&gt;Combining inline images into your (cached) stylesheets is a way to reduce HTTP&lt;br /&gt;requests and avoid increasing the size of your pages. Inline images are not yet&lt;br /&gt;supported across all major browsers.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Reducing the number of HTTP requests in your page is the&lt;br /&gt;place to start. This is the most important guideline for improving performance&lt;br /&gt;for first time visitors. As described in &lt;span class=SpellE&gt;Tenni&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;Theurer's&lt;/span&gt; &lt;span class=SpellE&gt;blog&lt;/span&gt; post Browser Cache&lt;br /&gt;Usage - Exposed&lt;span class=GramE&gt;!,&lt;/span&gt; 40-60% of daily visitors to your&lt;br /&gt;site come in with an empty cache. Making your page fast for these first time&lt;br /&gt;visitors is &lt;span class=GramE&gt;key&lt;/span&gt; to a better user experience.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Use a Content&lt;br /&gt;Delivery Network&lt;/u&gt;&lt;/b&gt;: Server&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The user's proximity to your web server has an impact on&lt;br /&gt;response times. Deploying your content across multiple, geographically&lt;br /&gt;dispersed servers will make your pages load faster from the user's perspective.&lt;br /&gt;But where should you start?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;As a first step to implementing geographically dispersed&lt;br /&gt;content, don't attempt to redesign your web application to work in a&lt;br /&gt;distributed architecture. Depending on the application, changing the&lt;br /&gt;architecture could include daunting tasks such as synchronizing session state&lt;br /&gt;and replicating database transactions across server locations. Attempts to&lt;br /&gt;reduce the distance between users and your content could be delayed by, or&lt;br /&gt;never pass, this application architecture step. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Remember that 80-90% of the end-user response time is spent&lt;br /&gt;downloading all the components in the page: images, stylesheets, scripts, &lt;span&lt;br /&gt;class=GramE&gt;Flash&lt;/span&gt;, etc. This is the Performance Golden Rule. Rather than&lt;br /&gt;starting with the difficult task of redesigning your application architecture,&lt;br /&gt;it's better to first disperse your static content. This not only achieves a&lt;br /&gt;bigger reduction in response times, but it's easier thanks to content delivery&lt;br /&gt;networks.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;i style='mso-bidi-font-style:normal'&gt;&lt;u&gt;A content delivery&lt;br /&gt;network (CDN) is a collection of web servers distributed across multiple&lt;br /&gt;locations to deliver content more efficiently to users. The server selected for&lt;br /&gt;delivering content to a specific user is typically based on a measure of&lt;br /&gt;network proximity. For example, the server with the fewest network hops or the&lt;br /&gt;server with the quickest response time is chosen.&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Some large Internet companies own their own CDN, but it's&lt;br /&gt;cost-effective to use a CDN service provider, such as &lt;span class=SpellE&gt;Akamai&lt;/span&gt;&lt;br /&gt;Technologies, Mirror Image Internet, or Limelight Networks. For start-up&lt;br /&gt;companies and private web sites, the cost of a CDN service can be prohibitive,&lt;br /&gt;but as your target audience grows larger and becomes more global, a CDN is&lt;br /&gt;necessary to achieve fast response times. At Yahoo!, properties that moved&lt;br /&gt;static content off their application web servers to a CDN improved end-user&lt;br /&gt;response times by 20% or more. Switching to a CDN is a relatively easy code&lt;br /&gt;change that will dramatically improve the speed of your web site.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Add an Expires or&lt;br /&gt;a Cache-Control Header&lt;/u&gt;: Server&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;There are two things in this rule:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;For static&lt;br /&gt;components&lt;/u&gt;&lt;/b&gt;&lt;i style='mso-bidi-font-style:normal'&gt;&lt;u&gt;: implement&lt;br /&gt;&amp;quot;Never expire&amp;quot; policy by setting far future Expires header &lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;i style='mso-bidi-font-style:normal'&gt;&lt;u&gt;&lt;o:p&gt;&lt;span&lt;br /&gt; style='text-decoration:none'&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;For dynamic&lt;br /&gt;components&lt;/u&gt;&lt;/b&gt;&lt;i style='mso-bidi-font-style:normal'&gt;&lt;u&gt;: use an appropriate&lt;br /&gt;Cache-Control header to help the browser with conditional requests &lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Web page designs are getting richer and richer, which means&lt;br /&gt;more scripts, stylesheets, images, and Flash in the page. A first-time visitor&lt;br /&gt;to your page may have to make several HTTP requests, but by using the Expires&lt;br /&gt;header you make those components cacheable. This avoids unnecessary HTTP&lt;br /&gt;requests on subsequent page views. Expires headers are most often used with&lt;br /&gt;images, but they should be used on all components including scripts,&lt;br /&gt;stylesheets, and Flash components.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Browsers (and proxies) use a cache to reduce the number and&lt;br /&gt;size of HTTP requests, making web pages load faster. A web server uses the&lt;br /&gt;Expires header in the HTTP response to tell the client how long a component can&lt;br /&gt;be cached. This is a far future Expires header, telling the browser that this&lt;br /&gt;response won't be stale until April 15, 2010. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Expires: Thu, 15&lt;br /&gt;Apr 2010 20:00:00 GMT&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;If your server is Apache, use the &lt;span class=SpellE&gt;ExpiresDefault&lt;/span&gt;&lt;br /&gt;directive to set an expiration date relative to the current date. This example&lt;br /&gt;of the &lt;span class=SpellE&gt;ExpiresDefault&lt;/span&gt; directive sets the Expires date&lt;br /&gt;10 years out from the time of the request.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&lt;br /&gt;class=SpellE&gt;ExpiresDefault&lt;/span&gt; &amp;quot;access plus 10 years&amp;quot;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Keep in mind, if you use a far future Expires header you&lt;br /&gt;have to change the component's filename whenever the component changes. At&lt;br /&gt;Yahoo! we often make this step part of the build process: a version number is&lt;br /&gt;embedded in the component's filename, for example, yahoo_2.0.6.js.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Using a far future Expires header affects page views only&lt;br /&gt;after a user has already visited your site. It has no effect on the number of HTTP&lt;br /&gt;requests when a user visits your site for the first time and the browser's&lt;br /&gt;cache is empty. Therefore the impact of this performance improvement depends on&lt;br /&gt;how often users hit your pages with a primed cache. (A &amp;quot;primed cache&amp;quot;&lt;br /&gt;already contains all of the components in the page.) We measured this at Yahoo!&lt;br /&gt;and found the number of page views with a primed cache is 75-85%. By using a&lt;br /&gt;far future Expires header, you increase the number of components that are&lt;br /&gt;cached by the browser and re-used on subsequent page views without sending a&lt;br /&gt;single byte over the user's Internet connection.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Gzip Components&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;tag: server&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The time it takes to transfer an HTTP request and response&lt;br /&gt;across the network can be significantly reduced by decisions made by front-end&lt;br /&gt;engineers. It's true that the end-user's bandwidth speed, Internet service&lt;br /&gt;provider, proximity to peering exchange points, etc. are beyond the control of&lt;br /&gt;the development team. But there are other variables that affect response times.&lt;br /&gt;Compression reduces response times by reducing the size of the HTTP response.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Starting with HTTP/1.1, web clients indicate support for&lt;br /&gt;compression with the Accept-Encoding header in the HTTP request.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Accept-Encoding:&lt;br /&gt;gzip, deflate &lt;span class=GramE&gt;If&lt;/span&gt; the web server sees this header in&lt;br /&gt;the request, it may compress the response using one of the methods listed by&lt;br /&gt;the client. The web server notifies the web client of this via the&lt;br /&gt;Content-Encoding header in the response.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;Content-Encoding: gzipGzip is the most popular and effective compression&lt;br /&gt;method at this time. It was developed by the GNU project and standardized by&lt;br /&gt;RFC 1952. The only other compression format you're likely to see is deflate,&lt;br /&gt;but it's less effective and less popular. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Gzipping generally reduces the response size by about 70%.&lt;br /&gt;Approximately 90% of today's Internet traffic travels through browsers that&lt;br /&gt;claim to support gzip. If you use Apache, the module configuring gzip depends&lt;br /&gt;on your version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;There are known issues with browsers and proxies that may&lt;br /&gt;cause a mismatch in what the browser expects and what it receives with regard&lt;br /&gt;to compressed content. Fortunately, these edge cases are dwindling as the use&lt;br /&gt;of older browsers drops off. The Apache modules help out by adding appropriate&lt;br /&gt;Vary response headers automatically. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Servers choose what to gzip based on file type, but are&lt;br /&gt;typically too limited in what they decide to compress. Most web sites gzip&lt;br /&gt;their HTML documents. It's also worthwhile to gzip your scripts and style sheets,&lt;br /&gt;but many web sites miss this opportunity. In fact, it's worthwhile to compress&lt;br /&gt;any text response including XML and JSON. Image and PDF files should not be&lt;br /&gt;gzipped because they are already compressed. Trying to gzip them not only&lt;br /&gt;wastes CPU but can potentially increase file sizes. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Gzipping as many file types as possible is an easy way to&lt;br /&gt;reduce page weight and accelerate the user experience.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Put Style sheets&lt;br /&gt;at the Top&lt;/u&gt;&lt;/b&gt;: css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;While researching performance at Yahoo!, we discovered that&lt;br /&gt;moving style sheets to the document HEAD makes pages appear to be loading&lt;br /&gt;faster. This is because putting style sheets in the HEAD allows the page to&lt;br /&gt;render progressively. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Front-end engineers that care about performance want a page&lt;br /&gt;to load progressively; that is, we want the browser to display whatever content&lt;br /&gt;it has as soon as possible. This is especially important for pages with a lot&lt;br /&gt;of content and for users on slower Internet connections. The importance of&lt;br /&gt;giving users visual feedback, such as progress indicators, has been well&lt;br /&gt;researched and documented. In our case the HTML page is the progress indicator!&lt;br /&gt;When the browser loads the page progressively the header, the navigation bar,&lt;br /&gt;the logo at the top, etc. all serve as visual feedback for the user who is&lt;br /&gt;waiting for the page. This improves the overall user experience.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The problem with putting style sheets near the bottom of the&lt;br /&gt;document is that it prohibits progressive rendering in many browsers, including&lt;br /&gt;Internet Explorer. These browsers block rendering to avoid having to redraw&lt;br /&gt;elements of the page if their styles change. The user is stuck viewing a blank&lt;br /&gt;white page. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The HTML specification clearly states that stylesheets are&lt;br /&gt;to be included in the HEAD of the page: &amp;quot;Unlike A, [LINK] may only appear&lt;br /&gt;in the HEAD section of a document, although it may appear any number of&lt;br /&gt;times.&amp;quot; Neither of the alternatives, the blank white screen or flash of &lt;span&lt;br /&gt;class=SpellE&gt;unstyled&lt;/span&gt; content, are worth the risk. The optimal solution&lt;br /&gt;is to follow the HTML specification and load your stylesheets in the document&lt;br /&gt;HEAD.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Put Scripts at the&lt;br /&gt;Bottom&lt;/u&gt;&lt;/b&gt;: &lt;span class=SpellE&gt;javascript&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The problem caused by scripts is that they block parallel&lt;br /&gt;downloads. The HTTP/1.1 specification suggests that browsers download no more&lt;br /&gt;than two components in parallel per hostname. If you serve your images from&lt;br /&gt;multiple hostnames, you can get more than two downloads to occur in parallel.&lt;br /&gt;While a script is downloading, however, the browser won't start any other&lt;br /&gt;downloads, even on different hostnames. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;In some situations it's not easy to move scripts to the&lt;br /&gt;bottom. If, for example, the script uses document. &lt;span class=GramE&gt;write&lt;/span&gt;&lt;br /&gt;to insert part of the page's content, it can't be moved lower in the page.&lt;br /&gt;There might also be scoping issues. In many cases, there are ways to workaround&lt;br /&gt;these situations.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;An alternative suggestion that often comes up is to use&lt;br /&gt;deferred scripts. The DEFER attribute indicates that the script does not&lt;br /&gt;contain &lt;span class=SpellE&gt;document.write&lt;/span&gt;, and is a clue to browsers&lt;br /&gt;that they can continue rendering. Unfortunately, &lt;span class=SpellE&gt;Firefox&lt;/span&gt;&lt;br /&gt;doesn't support the DEFER attribute. In Internet Explorer, the script may be&lt;br /&gt;deferred, but not as much as desired. If a script can be deferred, it can also&lt;br /&gt;be moved to the bottom of the page. That will make your web pages load faster.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Avoid CSS&lt;br /&gt;Expressions&lt;/u&gt;&lt;/b&gt;: css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;CSS expressions are a powerful (and dangerous) way to set&lt;br /&gt;CSS properties dynamically. They're supported in Internet Explorer, starting&lt;br /&gt;with version 5. As an example, the background color could be set to alternate&lt;br /&gt;every hour using CSS expressions.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&lt;br /&gt;class=GramE&gt;background-color&lt;/span&gt;: expression( (new Date()).&lt;span&lt;br /&gt;class=SpellE&gt;getHours&lt;/span&gt;()%2 ? &amp;quot;#B8D4FF&lt;span class=GramE&gt;&amp;quot; :&lt;/span&gt;&lt;br /&gt;&amp;quot;#F08A00&amp;quot; );&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;As shown here, the expression method accepts a JavaScript&lt;br /&gt;expression. The CSS property is set to the result of evaluating the JavaScript&lt;br /&gt;expression. The expression method is ignored by other browsers, so it is useful&lt;br /&gt;for setting properties in Internet Explorer needed to create a consistent&lt;br /&gt;experience across browsers.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The problem with expressions is that they are evaluated more&lt;br /&gt;frequently than most people expect. Not only are they evaluated when the page is&lt;br /&gt;rendered and resized, but also when the page is scrolled and even when the user&lt;br /&gt;moves the mouse over the page. Adding a counter to the CSS expression allows us&lt;br /&gt;to keep track of when and how often a CSS expression is evaluated. Moving the&lt;br /&gt;mouse around the page can easily generate more than 10,000 evaluations.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One way to reduce the number of times your CSS expression is&lt;br /&gt;evaluated is to use one-time expressions, where the first time the expression&lt;br /&gt;is evaluated it sets the style property to an explicit value, which replaces&lt;br /&gt;the CSS expression. If the style property must be set dynamically throughout&lt;br /&gt;the life of the page, using event handlers instead of CSS expressions is an&lt;br /&gt;alternative approach. If you must use CSS expressions, remember that they may&lt;br /&gt;be evaluated thousands of times and could affect the performance of your page.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Make JavaScript&lt;br /&gt;and CSS External&lt;/u&gt;&lt;/b&gt;: JavaScript, css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Many of these performance rules deal with how external&lt;br /&gt;components are managed. However, before these considerations arise you should&lt;br /&gt;ask a more basic question: Should JavaScript and CSS &lt;span class=GramE&gt;be&lt;/span&gt;&lt;br /&gt;contained in external files, or &lt;span class=SpellE&gt;inlined&lt;/span&gt; in the page&lt;br /&gt;itself?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Using external files in the real world generally produces&lt;br /&gt;faster pages because the JavaScript and CSS files are cached by the browser.&lt;br /&gt;JavaScript and CSS that are &lt;span class=SpellE&gt;inlined&lt;/span&gt; in HTML documents&lt;br /&gt;get downloaded every time the HTML document is requested. This reduces the&lt;br /&gt;number of HTTP requests that are needed, but increases the size of the HTML&lt;br /&gt;document. On the other hand, if the JavaScript and CSS are in external files&lt;br /&gt;cached by the browser, the size of the HTML document is reduced without&lt;br /&gt;increasing the number of HTTP requests. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The key factor, then, is the frequency with which external&lt;br /&gt;JavaScript and CSS components are cached relative to the number of HTML&lt;br /&gt;documents requested. This factor, although difficult to quantify, can be gauged&lt;br /&gt;using various metrics. If users on your site have multiple page views per&lt;br /&gt;session and many of your pages re-use the same scripts and stylesheets, there&lt;br /&gt;is a greater potential benefit from cached external files. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Many web sites fall in the middle of these metrics. For&lt;br /&gt;these sites, the best solution generally is to deploy the JavaScript and CSS as&lt;br /&gt;external files. The only exception where &lt;span class=SpellE&gt;inlining&lt;/span&gt; is&lt;br /&gt;preferable is with home pages, such as &lt;span class=SpellE&gt;Yahoo!'s&lt;/span&gt; front&lt;br /&gt;page and My Yahoo&lt;span class=GramE&gt;!.&lt;/span&gt; Home pages that have few (perhaps&lt;br /&gt;only one) page view per session may find that &lt;span class=SpellE&gt;inlining&lt;/span&gt;&lt;br /&gt;JavaScript and CSS results in faster end-user response times.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For front pages that are typically the first of many page&lt;br /&gt;views, there are techniques that leverage the reduction of HTTP requests that &lt;span&lt;br /&gt;class=SpellE&gt;inlining&lt;/span&gt; provides, as well as the caching benefits achieved&lt;br /&gt;through using external files. One such technique is to inline JavaScript and&lt;br /&gt;CSS in the front page, but dynamically &lt;span class=GramE&gt;download&lt;/span&gt; the&lt;br /&gt;external files after the page has finished loading. Subsequent pages would&lt;br /&gt;reference the external files that should already be in the browser's cache.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Reduce DNS Lookups&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The Domain Name System (DNS) maps hostnames to IP addresses,&lt;br /&gt;just as phonebooks map people's names to their phone numbers. When you type&lt;br /&gt;www.yahoo.com into your browser, a DNS &lt;span class=SpellE&gt;resolver&lt;/span&gt;&lt;br /&gt;contacted by the browser returns that server's IP address. DNS has a cost. It&lt;br /&gt;typically takes 20-120 milliseconds for DNS to lookup the IP address for a&lt;br /&gt;given hostname. The browser can't download anything from this hostname until&lt;br /&gt;the DNS lookup is completed. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;DNS lookups are cached for better performance. This caching&lt;br /&gt;can occur on a special caching server, maintained by the user's ISP or local&lt;br /&gt;area network, but there is also caching that occurs on the individual user's&lt;br /&gt;computer. The DNS information remains in the operating system's DNS cache (the&lt;br /&gt;&amp;quot;DNS Client service&amp;quot; on Microsoft Windows). Most browsers have their&lt;br /&gt;own caches, separate from the operating system's cache. As long as the browser&lt;br /&gt;keeps a DNS record in its own cache, it doesn't bother the operating system&lt;br /&gt;with a request for the record.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Internet Explorer caches DNS lookups for 30 minutes by&lt;br /&gt;default, as specified by the &lt;span class=SpellE&gt;DnsCacheTimeout&lt;/span&gt; registry&lt;br /&gt;setting. &lt;span class=SpellE&gt;Firefox&lt;/span&gt; caches DNS lookups for 1 minute,&lt;br /&gt;controlled by the &lt;span class=SpellE&gt;network.dnsCacheExpiration&lt;/span&gt;&lt;br /&gt;configuration setting. (&lt;span class=SpellE&gt;Fasterfox&lt;/span&gt; changes this to 1&lt;br /&gt;hour.)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;When the client's DNS cache is empty (for both the browser&lt;br /&gt;and the operating system), the number of DNS lookups is equal to the number of&lt;br /&gt;unique hostnames in the web page. This includes the hostnames used in the&lt;br /&gt;page's URL, images, script files, stylesheets, Flash objects, etc. Reducing the&lt;br /&gt;number of unique hostnames reduces the number of DNS lookups. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Reducing the number of unique hostnames has the potential to&lt;br /&gt;reduce the amount of parallel downloading that takes place in the page.&lt;br /&gt;Avoiding DNS lookups cuts response times, but reducing parallel downloads may&lt;br /&gt;increase response times. My guideline is to split these components across at&lt;br /&gt;least two but no more than four hostnames. This &lt;span class=GramE&gt;results&lt;/span&gt;&lt;br /&gt;in a good compromise between reducing DNS lookups and allowing a high degree of&lt;br /&gt;parallel downloads.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Minify JavaScript&lt;br /&gt;and CSS&lt;/u&gt;&lt;/b&gt;: &lt;span class=SpellE&gt;javascript&lt;/span&gt;, css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;Minification&lt;/span&gt; is the practice of&lt;br /&gt;removing unnecessary characters from code to reduce its size thereby improving&lt;br /&gt;load times. When code is minified all comments are removed, as well as unneeded&lt;br /&gt;white space characters (space, newline, and tab). In the case of JavaScript,&lt;br /&gt;this improves response time performance because the size of the downloaded file&lt;br /&gt;is reduced. Two popular tools for minifying JavaScript code are &lt;span&lt;br /&gt;class=SpellE&gt;JSMin&lt;/span&gt; and YUI Compressor. The YUI compressor can also&lt;br /&gt;minify CSS.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Obfuscation is an alternative optimization that can be&lt;br /&gt;applied to source code. It's more complex than &lt;span class=SpellE&gt;minification&lt;/span&gt;&lt;br /&gt;and thus more likely to generate bugs as a result of the obfuscation step&lt;br /&gt;itself. In a survey of ten top &lt;st1:country-region w:st="on"&gt;&lt;st1:place w:st="on"&gt;U.S.&lt;/st1:place&gt;&lt;/st1:country-region&gt;&lt;br /&gt;web sites, &lt;span class=SpellE&gt;minification&lt;/span&gt; achieved a 21% size reduction&lt;br /&gt;versus 25% for obfuscation. Although obfuscation has a higher size reduction,&lt;br /&gt;minifying JavaScript is less risky.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;In addition to minifying external scripts and styles, &lt;span&lt;br /&gt;class=SpellE&gt;inlined&lt;/span&gt; &amp;lt;script&amp;gt; and &amp;lt;style&amp;gt; blocks can and&lt;br /&gt;should also be minified. Even if you gzip your scripts and styles, minifying&lt;br /&gt;them will still reduce the size by 5% or more. As the use and size of&lt;br /&gt;JavaScript and CSS increases, so will the savings gained by minifying your&lt;br /&gt;code.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Avoid Redirects&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Redirects are accomplished using the 301 and 302 status&lt;br /&gt;codes. Here's an example of the HTTP headers in a 301 response:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HTTP/1.1 301&lt;br /&gt;Moved Permanently&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Location:&lt;br /&gt;http://example.com/newuri&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Content-Type:&lt;br /&gt;text/html&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The browser automatically takes the user to the URL&lt;br /&gt;specified in the Location field. All the information necessary for a redirect&lt;br /&gt;is in the headers. The body of the response is typically empty. Despite their&lt;br /&gt;names, neither a 301 nor a 302 response is cached in practice unless additional&lt;br /&gt;headers, such as Expires or Cache-Control, indicate it should be. The &lt;span&lt;br /&gt;class=GramE&gt;meta&lt;/span&gt; refresh tag and JavaScript are other ways to direct&lt;br /&gt;users to a different URL, but if you must do a redirect, the preferred&lt;br /&gt;technique is to use the standard 3xx HTTP status codes, primarily to ensure the&lt;br /&gt;back button works correctly.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The main thing to remember is that redirects slow down the&lt;br /&gt;user experience. Inserting a redirect between the user and the HTML document&lt;br /&gt;delays everything in the page since nothing in the page can be rendered and no&lt;br /&gt;components can start being downloaded until the HTML document has arrived.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One of the most wasteful redirects happens frequently and&lt;br /&gt;web developers are generally not aware of it. It occurs when a trailing slash&lt;br /&gt;(/) is missing from a URL that should otherwise have one. &lt;span class=GramE&gt;For&lt;br /&gt;example, going to http://astrology.yahoo.com/astrology results in a 301&lt;br /&gt;response containing a redirect to http://astrology.yahoo.com/astrology/ (notice&lt;br /&gt;the added trailing slash).&lt;/span&gt; This is fixed in Apache by using Alias or &lt;span&lt;br /&gt;class=SpellE&gt;mod_rewrite&lt;/span&gt;, or the &lt;span class=SpellE&gt;DirectorySlash&lt;/span&gt;&lt;br /&gt;directive if you're using Apache handlers.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Connecting an old web site to a new one is another common&lt;br /&gt;use for redirects. Others include connecting different parts of a website and&lt;br /&gt;directing the user based on certain conditions (type of browser, type of user&lt;br /&gt;account, etc.). Using a redirect to connect two web sites is simple and&lt;br /&gt;requires little additional coding. Although using redirects in these situations&lt;br /&gt;reduces the complexity for developers, it degrades the user experience.&lt;br /&gt;Alternatives for this use of redirects include using Alias and &lt;span&lt;br /&gt;class=SpellE&gt;mod_rewrite&lt;/span&gt; if the two code paths are hosted on the same&lt;br /&gt;server. If a domain name change is the cause of using redirects, an alternative&lt;br /&gt;is to create a CNAME (a DNS record that creates an alias pointing from one&lt;br /&gt;domain name to another) in combination with Alias or &lt;span class=SpellE&gt;mod_rewrite&lt;/span&gt;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Remove Duplicate&lt;br /&gt;Scripts&lt;/u&gt;&lt;/b&gt;: JavaScript&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;It hurts performance to include the same JavaScript file&lt;br /&gt;twice in one page. This isn't as unusual as you might think. A review of the&lt;br /&gt;ten top &lt;st1:country-region w:st="on"&gt;&lt;st1:place w:st="on"&gt;U.S.&lt;/st1:place&gt;&lt;/st1:country-region&gt;&lt;br /&gt;web sites shows that two of them contain a duplicated script. Two main factors&lt;br /&gt;increase the odds of a script being duplicated in a single web page: team size&lt;br /&gt;and number of scripts. When it does happen, duplicate scripts hurt performance&lt;br /&gt;by creating unnecessary HTTP requests and wasted JavaScript execution.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Unnecessary HTTP requests happen in Internet Explorer, but&lt;br /&gt;not in &lt;span class=SpellE&gt;Firefox&lt;/span&gt;. In Internet Explorer, if an external&lt;br /&gt;script is included twice and is not cacheable, it generates two HTTP requests&lt;br /&gt;during page loading. Even if the script is cacheable, extra HTTP requests occur&lt;br /&gt;when the user reloads the page.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;In addition to generating wasteful HTTP requests, time is&lt;br /&gt;wasted evaluating the script multiple times. This redundant JavaScript&lt;br /&gt;execution happens in both &lt;span class=SpellE&gt;Firefox&lt;/span&gt; and Internet&lt;br /&gt;Explorer, regardless of whether the script is cacheable.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One way to avoid accidentally including the same script&lt;br /&gt;twice is to implement a script management module in your &lt;span class=SpellE&gt;templating&lt;/span&gt;&lt;br /&gt;system. The typical way to include a script is to use the SCRIPT tag in your&lt;br /&gt;HTML page.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;script&lt;br /&gt;type=&amp;quot;text/&lt;span class=SpellE&gt;javascript&lt;/span&gt;&amp;quot; &lt;span class=SpellE&gt;src&lt;/span&gt;=&amp;quot;menu_1.0.17.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;An&lt;br /&gt;alternative in PHP would be to create a function called &lt;span class=SpellE&gt;insertScript&lt;/span&gt;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;?&lt;span&lt;br /&gt;class=SpellE&gt;php&lt;/span&gt; &lt;span class=SpellE&gt;insertScript&lt;/span&gt;(&amp;quot;&lt;span&lt;br /&gt;class=SpellE&gt;menu.js&lt;/span&gt;&amp;quot;) ?&amp;gt;In addition to preventing the same&lt;br /&gt;script from being inserted multiple times, this function could handle other&lt;br /&gt;issues with scripts, such as dependency checking and adding version numbers to&lt;br /&gt;script filenames to support far future Expires headers.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Configure &lt;span&lt;br /&gt;class=SpellE&gt;ETags&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;: server&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Entity tags (&lt;span class=SpellE&gt;ETags&lt;/span&gt;) are a&lt;br /&gt;mechanism that web servers and browsers use to determine whether the component&lt;br /&gt;in the browser's cache matches the one on the origin server. (An&lt;br /&gt;&amp;quot;entity&amp;quot; is another word a &amp;quot;component&amp;quot;: images, scripts,&lt;br /&gt;stylesheets, etc.) &lt;span class=SpellE&gt;ETags&lt;/span&gt; were added to provide a&lt;br /&gt;mechanism for validating entities that is more flexible than the last-modified&lt;br /&gt;date. An &lt;span class=SpellE&gt;ETag&lt;/span&gt; is a string that uniquely identifies a&lt;br /&gt;specific version of a component. The only format constraints are that the&lt;br /&gt;string be quoted. The origin server specifies the component's &lt;span&lt;br /&gt;class=SpellE&gt;ETag&lt;/span&gt; using the &lt;span class=SpellE&gt;ETag&lt;/span&gt; response&lt;br /&gt;header.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HTTP/1.1 200 OK&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Last-Modified:&lt;br /&gt;Tue, 12 Dec 2006 03:03:59 GMT&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&lt;br /&gt;class=SpellE&gt;ETag&lt;/span&gt;: &amp;quot;10c24bc-4ab-457e1c1f&amp;quot;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Content-Length:&lt;br /&gt;12195&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Later, if the browser has to validate a component, it uses&lt;br /&gt;the If-None-Match header to pass the &lt;span class=SpellE&gt;ETag&lt;/span&gt; back to the&lt;br /&gt;origin server. If the &lt;span class=SpellE&gt;ETags&lt;/span&gt; match, a 304 status code&lt;br /&gt;is returned reducing the response by 12195 bytes for this example. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GET /&lt;span&lt;br /&gt;class=SpellE&gt;i/yahoo.gif&lt;/span&gt; HTTP/1.1&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Host:&lt;br /&gt;us.yimg.com&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If-None-Match:&lt;br /&gt;&amp;quot;10c24bc-4ab-457e1c1f&amp;quot;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HTTP/1.1 304 Not&lt;br /&gt;Modified&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The problem with &lt;span class=SpellE&gt;ETags&lt;/span&gt; is that&lt;br /&gt;they typically are constructed using attributes that make them unique to a&lt;br /&gt;specific server hosting a site. &lt;span class=SpellE&gt;ETags&lt;/span&gt; won't match&lt;br /&gt;when a browser gets the original component from one server and later tries to&lt;br /&gt;validate that component on a different server, a situation that is all too&lt;br /&gt;common on Web sites that use a cluster of servers to handle requests. By&lt;br /&gt;default, both Apache and IIS embed data in the &lt;span class=SpellE&gt;ETag&lt;/span&gt;&lt;br /&gt;that dramatically reduces the odds of the validity test succeeding on web sites&lt;br /&gt;with multiple servers. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The &lt;span class=SpellE&gt;ETag&lt;/span&gt; format for Apache 1.3 and&lt;br /&gt;2.x is &lt;span class=SpellE&gt;inode&lt;/span&gt;-size-timestamp. Although a given file&lt;br /&gt;may reside in the same directory across multiple servers, and have the same&lt;br /&gt;file size, permissions, timestamp, etc., its &lt;span class=SpellE&gt;inode&lt;/span&gt; is&lt;br /&gt;different from one server to the next. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;IIS 5.0 and 6.0 have a similar issue with &lt;span&lt;br /&gt;class=SpellE&gt;ETags&lt;/span&gt;. The format for &lt;span class=SpellE&gt;ETags&lt;/span&gt; on&lt;br /&gt;IIS is &lt;span class=SpellE&gt;Filetimestamp&lt;span class=GramE&gt;:ChangeNumber&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;A &lt;span class=SpellE&gt;ChangeNumber&lt;/span&gt; is a counter used to track&lt;br /&gt;configuration changes to IIS. It's unlikely that the &lt;span class=SpellE&gt;ChangeNumber&lt;/span&gt;&lt;br /&gt;is the same across all IIS servers behind a web site. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The end result is &lt;span class=SpellE&gt;ETags&lt;/span&gt; generated&lt;br /&gt;by Apache and IIS for the exact same component won't match from one server to&lt;br /&gt;another. If the &lt;span class=SpellE&gt;ETags&lt;/span&gt; don't match, the user doesn't&lt;br /&gt;receive the small, fast 304 response that &lt;span class=SpellE&gt;ETags&lt;/span&gt; were&lt;br /&gt;designed for; instead, they'll get a normal 200 response along with all the&lt;br /&gt;data for the component. If you host your web site on just one server, this&lt;br /&gt;isn't a problem. But if you have multiple servers hosting your web &lt;span&lt;br /&gt;class=GramE&gt;site,&lt;/span&gt; and you're using Apache or IIS with the default &lt;span&lt;br /&gt;class=SpellE&gt;ETag&lt;/span&gt; configuration, your users are getting slower pages,&lt;br /&gt;your servers have a higher load, you're consuming greater bandwidth, and&lt;br /&gt;proxies aren't caching your content efficiently. Even if your components have a&lt;br /&gt;far future Expires header, a conditional GET request is still made whenever the&lt;br /&gt;user hits Reload or Refresh. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;If you're not taking advantage of the flexible validation&lt;br /&gt;model that &lt;span class=SpellE&gt;ETags&lt;/span&gt; provide, it's better to just remove&lt;br /&gt;the &lt;span class=SpellE&gt;ETag&lt;/span&gt; altogether. The Last-Modified header&lt;br /&gt;validates based on the component's timestamp. And removing the &lt;span&lt;br /&gt;class=SpellE&gt;ETag&lt;/span&gt; reduces the size of the HTTP headers in both the&lt;br /&gt;response and subsequent requests. This Microsoft Support article describes how&lt;br /&gt;to remove &lt;span class=SpellE&gt;ETags&lt;/span&gt;. In Apache, this is done by simply&lt;br /&gt;adding the following line to your Apache configuration file: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Make &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; Cacheable&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One of the cited benefits of &lt;st1:City w:st="on"&gt;&lt;st1:place&lt;br /&gt; w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; is that it provides instantaneous&lt;br /&gt;feedback to the user because it requests information asynchronously from the&lt;br /&gt;backend web server. However, using &lt;st1:City w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;br /&gt;is no guarantee that the user won't be twiddling his thumbs waiting for those&lt;br /&gt;asynchronous JavaScript and XML responses to return. In many applications,&lt;br /&gt;whether or not the user is kept waiting depends on how &lt;st1:City w:st="on"&gt;&lt;st1:place&lt;br /&gt; w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; is used. For example, in a web-based&lt;br /&gt;email client the user will be kept waiting for the results of an &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; request to find all&lt;br /&gt;the email messages that match their search criteria. It's important to remember&lt;br /&gt;that &amp;quot;asynchronous&amp;quot; does not imply &amp;quot;instantaneous&amp;quot;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;To improve performance, it's important to optimize these &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; responses. The most&lt;br /&gt;important way to improve the performance of &lt;st1:City w:st="on"&gt;&lt;st1:place&lt;br /&gt; w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; is to make the responses cacheable, as&lt;br /&gt;discussed in Add an Expires or a Cache-Control Header. Some of the other rules&lt;br /&gt;also apply to &lt;st1:City w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt;:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Gzip Components&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Reduce DNS Lookups&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Minify JavaScript&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Avoid Redirects&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Configure &lt;span class=SpellE&gt;ETags&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Let's look at an example. A Web 2.0 email client might use &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; to download the&lt;br /&gt;user's address book for &lt;span class=SpellE&gt;autocompletion&lt;/span&gt;. If the user&lt;br /&gt;hasn't modified her address book since the last time she used the email web&lt;br /&gt;app, the previous address book response could be read from cache if that &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; response was made&lt;br /&gt;cacheable with a future Expires or Cache-Control header. The browser must be informed&lt;br /&gt;when to use a previously cached address book response versus requesting a new&lt;br /&gt;one. This could be done by adding a timestamp to the address book Ajax URL&lt;br /&gt;indicating the last time the user modified her address book, for example,&lt;br /&gt;&amp;amp;t=1190241612. If the address book hasn't been modified since the last&lt;br /&gt;download, the timestamp will be the same and the address book will be read from&lt;br /&gt;the browser's cache eliminating an extra HTTP roundtrip. If the user has&lt;br /&gt;modified her address book, the timestamp ensures the new URL doesn't match the&lt;br /&gt;cached response, and the browser will request the updated address book entries.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Even though your &lt;st1:City w:st="on"&gt;&lt;st1:place w:st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;br /&gt;responses are created dynamically, and might only be applicable to a single&lt;br /&gt;user, they can still be cached. Doing so will make your Web 2.0 apps faster.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Flush the Buffer&lt;br /&gt;Early&lt;/u&gt;&lt;/b&gt;: server&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;When users request a page, it can take anywhere from 200 to&lt;br /&gt;500ms for the backend server to stitch together the HTML page. During this&lt;br /&gt;time, the browser is idle as it waits for the data to arrive. In PHP you have&lt;br /&gt;the function &lt;span class=GramE&gt;flush(&lt;/span&gt;). It allows you to send your&lt;br /&gt;partially ready HTML response to the browser so that the browser can start&lt;br /&gt;fetching components while your backend is busy with the rest of the HTML page.&lt;br /&gt;The benefit is mainly seen on busy &lt;span class=SpellE&gt;backends&lt;/span&gt; or light &lt;span&lt;br /&gt;class=SpellE&gt;frontends&lt;/span&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;A good place to consider flushing is right after the HEAD&lt;br /&gt;because the HTML for the head is usually easier to produce and it allows you to&lt;br /&gt;include any CSS and JavaScript files for the browser to start fetching in&lt;br /&gt;parallel while the backend is still processing. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Example:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;... &amp;lt;&lt;span&lt;br /&gt;class=GramE&gt;!--&lt;/span&gt; css, &lt;span class=SpellE&gt;js&lt;/span&gt; --&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&amp;lt;/head&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&lt;br /&gt;class=GramE&gt;&amp;lt;?&lt;span class=SpellE&gt;php&lt;/span&gt;&lt;/span&gt; flush(); ?&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&amp;lt;&lt;span class=GramE&gt;body&lt;/span&gt;&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span&lt;br /&gt;style='mso-spacerun:yes'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;... &amp;lt;&lt;span&lt;br /&gt;class=GramE&gt;!--&lt;/span&gt; content --&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Yahoo! search pioneered research and real user testing to&lt;br /&gt;prove the benefits of using this technique.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Use&lt;br /&gt;GET&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt; for &lt;st1:City&lt;br /&gt;w:st="on"&gt;&lt;st1:place w:st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:City&gt; Requests&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;server&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The Yahoo! Mail team found that when using &lt;span&lt;br /&gt;class=SpellE&gt;XMLHttpRequest&lt;/span&gt;, POST is implemented in the browsers as a&lt;br /&gt;two-step process: sending the headers first, then sending data. So it's best to&lt;br /&gt;use GET, which only takes one TCP packet to send (unless you have a lot of&lt;br /&gt;cookies). The maximum URL length in IE is 2K, so if you send more than 2K data&lt;br /&gt;you might not be able to use GET. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;An interesting side affect is that POST without actually&lt;br /&gt;posting any data behaves like GET. Based on the HTTP specs, GET is meant for&lt;br /&gt;retrieving information, so it makes sense (semantically) to use GET when you're&lt;br /&gt;only requesting data, as opposed to sending data to be stored server-side. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Post-load&lt;br /&gt;Components&lt;/u&gt;&lt;/b&gt;: content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;You can take a closer look at your page and ask yourself:&lt;br /&gt;&amp;quot;What's absolutely required in order to render the page initially?&lt;span&lt;br /&gt;class=GramE&gt;&amp;quot;.&lt;/span&gt; The rest of the content and components can wait. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;JavaScript is an ideal candidate for splitting before and&lt;br /&gt;after the &lt;span class=SpellE&gt;onload&lt;/span&gt; event. For example if you have&lt;br /&gt;JavaScript code and libraries that do drag and drop and animations, those can&lt;br /&gt;wait, because dragging elements on the page comes after the initial rendering.&lt;br /&gt;Other places to look for candidates for post-loading include hidden content&lt;br /&gt;(content that appears after a user action) and images below the fold. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Tools to help you out in your effort: YUI Image Loader&lt;br /&gt;allows you to delay images below the fold and the YUI Get utility is an easy&lt;br /&gt;way to include JS and CSS on the fly. For an example in the wild take a look at&lt;br /&gt;Yahoo! Home Page with Firebug's Net Panel turned on. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;It's good when the performance goals are inline with other&lt;br /&gt;web development best practices. In this case, the idea of progressive&lt;br /&gt;enhancement tells us that JavaScript, when supported, can improve the user&lt;br /&gt;experience but you have to make sure the page works even without JavaScript. So&lt;br /&gt;after you've made sure the page works fine, you can enhance it with some&lt;br /&gt;post-loaded scripts that give you more bells and whistles such as drag and drop&lt;br /&gt;and animations. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Preload Components&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Preload may look like the opposite of post-load, but it&lt;br /&gt;actually has a different goal. By preloading components you can take advantage&lt;br /&gt;of the time the browser is idle and request components (like images, styles and&lt;br /&gt;scripts) you'll need in the future. This way when the user visits the next&lt;br /&gt;page, you could have most of the components already in the cache and your page&lt;br /&gt;will load much faster for the user. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;There are actually several types of preloading: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;Unconditional preload - as soon as &lt;span&lt;br /&gt;class=SpellE&gt;onload&lt;/span&gt; fires, you go ahead and fetch some extra components.&lt;/span&gt;&lt;br /&gt;Check google.com for an example of how a sprite image is requested &lt;span&lt;br /&gt;class=SpellE&gt;onload&lt;/span&gt;. This sprite image is not needed on the google.com&lt;br /&gt;homepage, but it is needed on the consecutive search result page. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Conditional preload - based on a user action you make an&lt;br /&gt;educated guess where the user is headed next and preload accordingly. On&lt;br /&gt;search.yahoo.com you can see how some extra components are requested after you&lt;br /&gt;start typing in the input box. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;Anticipated preload - preload in advance&lt;br /&gt;before launching a redesign.&lt;/span&gt; It often happens after a redesign that you&lt;br /&gt;hear: &amp;quot;The new site is cool, but it's slower than before&amp;quot;. Part of&lt;br /&gt;the problem could be that the users were visiting your old site with a full&lt;br /&gt;cache, but the new one is always an empty cache experience. You can mitigate&lt;br /&gt;this side effect by preloading some components before you even launched the&lt;br /&gt;redesign. Your old site can use the time the browser is idle and request images&lt;br /&gt;and scripts that will be used by the new site &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Reduce the Number&lt;br /&gt;of DOM Elements&lt;/u&gt;&lt;/b&gt;: content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;A complex page means more bytes to download and it also&lt;br /&gt;means slower DOM access in JavaScript. It makes a difference if you loop&lt;br /&gt;through 500 or 5000 DOM elements on the page when you want to add an event&lt;br /&gt;handler for example. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;A high number of DOM elements can be a symptom that there's&lt;br /&gt;something that should be improved with the markup of the page without&lt;br /&gt;necessarily removing content. Are you using nested tables for layout purposes?&lt;br /&gt;Are you throwing in more &amp;lt;div&amp;gt;s only to fix layout issues? Maybe there's&lt;br /&gt;a better and more semantically correct way to do your markup. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;A great help with layouts are the YUI CSS utilities: &lt;span&lt;br /&gt;class=SpellE&gt;grids.css&lt;/span&gt; can help you with the overall layout, &lt;span&lt;br /&gt;class=SpellE&gt;fonts.css&lt;/span&gt; and &lt;span class=SpellE&gt;reset.css&lt;/span&gt; can help&lt;br /&gt;you strip away the browser's defaults formatting. This is a chance to start&lt;br /&gt;fresh and think about your markup, for example use &amp;lt;div&amp;gt;s only when it&lt;br /&gt;makes sense semantically, and not because it renders a new line. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The number of DOM elements is easy to test, just type in&lt;br /&gt;Firebug's console:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;&lt;span class=GramE&gt;document.getElementsByTagName&lt;/span&gt;&lt;/span&gt;&lt;span&lt;br /&gt;class=GramE&gt;(&lt;/span&gt;'*').length &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;And how many DOM elements are too many? Check other similar&lt;br /&gt;pages that have good markup. For example the Yahoo! Home Page is a pretty busy&lt;br /&gt;page and still under 700 elements (HTML tags). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Split Components&lt;br /&gt;Across Domains&lt;/u&gt;&lt;/b&gt;: content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Splitting components allows you to maximize parallel&lt;br /&gt;downloads. Make sure you're using not more than 2-4 domains because of the DNS&lt;br /&gt;lookup penalty. For example, you can host your HTML and dynamic content on&lt;br /&gt;www.example.org and split static components between static1.example.org and&lt;br /&gt;static2.example.org &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For more information check &amp;quot;Maximizing Parallel&lt;br /&gt;Downloads in the &lt;st1:Street w:st="on"&gt;&lt;st1:address w:st="on"&gt;Carpool Lane&lt;/st1:address&gt;&lt;/st1:Street&gt;&amp;quot;&lt;br /&gt;by &lt;span class=SpellE&gt;Tenni&lt;/span&gt; &lt;span class=SpellE&gt;Theurer&lt;/span&gt; and Patty&lt;br /&gt;Chi. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Minimize the&lt;br /&gt;Number of &lt;span class=SpellE&gt;iframes&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;: content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;Iframes&lt;/span&gt; allow an HTML document to&lt;br /&gt;be inserted in the parent document. It's important to understand how &lt;span&lt;br /&gt;class=SpellE&gt;iframes&lt;/span&gt; work so they can be used effectively. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&amp;lt;&lt;span class=SpellE&gt;&lt;span class=GramE&gt;iframe&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;br /&gt;pros: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Helps with slow third-party content like badges and ads &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Security sandbox &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Download scripts in parallel &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&amp;lt;&lt;span class=SpellE&gt;&lt;span class=GramE&gt;iframe&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;br /&gt;cons: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Costly even if blank &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Blocks page &lt;span class=SpellE&gt;onload&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Non-semantic &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;No 404s&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;content&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;HTTP requests are expensive so making an HTTP request and&lt;br /&gt;getting a useless response (i.e. 404 &lt;span class=GramE&gt;Not&lt;/span&gt; Found) is&lt;br /&gt;totally unnecessary and will slow down the user experience without any benefit.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Some sites have helpful 404s &amp;quot;Did you mean X?&lt;span&lt;br /&gt;class=GramE&gt;&amp;quot;,&lt;/span&gt; which is great for the user experience but also&lt;br /&gt;wastes server resources (like database, etc). Particularly bad is when the link&lt;br /&gt;to an external JavaScript is wrong and the result is a 404. First, this&lt;br /&gt;download will block parallel downloads. Next the browser may try to parse the&lt;br /&gt;404 response body as if it were JavaScript code, trying to find something&lt;br /&gt;usable in it. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Reduce Cookie Size&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;cookie&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;HTTP cookies are used for a variety of reasons such as&lt;br /&gt;authentication and personalization. Information about cookies is exchanged in&lt;br /&gt;the HTTP headers between web servers and browsers. It's important to keep the&lt;br /&gt;size of cookies as low as possible to minimize the impact on the user's&lt;br /&gt;response time. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For more information check &amp;quot;When the Cookie&lt;br /&gt;Crumbles&amp;quot; by &lt;span class=SpellE&gt;Tenni&lt;/span&gt; &lt;span class=SpellE&gt;Theurer&lt;/span&gt;&lt;br /&gt;and Patty Chi. The take-home of this research: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Eliminate unnecessary cookies &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Keep cookie sizes as low as possible to minimize the impact&lt;br /&gt;on the user response time &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Be mindful of setting cookies at the appropriate domain&lt;br /&gt;level so other sub-domains are not affected &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Set an Expires date appropriately. An earlier Expires date&lt;br /&gt;or none removes the cookie sooner, improving the user response time &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Use Cookie-free&lt;br /&gt;Domains for Components&lt;/u&gt;&lt;/b&gt;: cookie&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;When the browser makes a request for a static image and&lt;br /&gt;sends cookies together with the request, the server doesn't have any use for&lt;br /&gt;those cookies. So they only create network traffic for no good reason. You&lt;br /&gt;should make sure static components are requested with cookie-free requests.&lt;br /&gt;Create a &lt;span class=SpellE&gt;subdomain&lt;/span&gt; and host all your static&lt;br /&gt;components there. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;If your domain is www.example.org, you can host your static&lt;br /&gt;components on static.example.org. However, if you've already set cookies on the&lt;br /&gt;top-level domain example.org as opposed to www.example.org, then all the&lt;br /&gt;requests to static.example.org will include those cookies. In this case, you&lt;br /&gt;can buy a whole new domain, host your static components there, and keep this&lt;br /&gt;domain cookie-free. Yahoo! uses yimg.com, &lt;span class=SpellE&gt;YouTube&lt;/span&gt;&lt;br /&gt;uses ytimg.com, &lt;span class=GramE&gt;Amazon&lt;/span&gt; uses images-amazon.com and so&lt;br /&gt;on. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Another benefit of hosting static components on a&lt;br /&gt;cookie-free domain is that some proxies might refuse to cache the components&lt;br /&gt;that are requested with cookies. On a related note, if you wonder if you should&lt;br /&gt;use example.org or www.example.org for your home page, consider the cookie&lt;br /&gt;impact. Omitting www leaves you no choice but to write cookies to&lt;br /&gt;*.example.org, so for performance reasons it's best to use the www &lt;span&lt;br /&gt;class=SpellE&gt;subdomain&lt;/span&gt; and write the cookies to that &lt;span class=SpellE&gt;subdomain&lt;/span&gt;.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Minimize DOM&lt;br /&gt;Access&lt;/u&gt;&lt;/b&gt;: &lt;span class=SpellE&gt;javascript&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Accessing DOM elements with JavaScript is slow so in order&lt;br /&gt;to have a more responsive page, you should: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Cache references to accessed elements &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Update nodes &amp;quot;offline&amp;quot; and then add them to the&lt;br /&gt;tree &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Avoid fixing layout with JavaScript &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For more information check the YUI theatre's &amp;quot;High&lt;br /&gt;Performance Ajax Applications&amp;quot; by &lt;span class=SpellE&gt;Julien&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;Lecomte&lt;/span&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Develop Smart&lt;br /&gt;Event Handlers&lt;/u&gt;&lt;/b&gt;: JavaScript&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Sometimes pages feel less responsive because of too many&lt;br /&gt;event handlers attached to different elements of the DOM tree which are then&lt;br /&gt;executed too often. That's why using event delegation is a good approach. If&lt;br /&gt;you have 10 buttons inside a div, attach only one event handler to the div&lt;br /&gt;wrapper, instead of one handler for each button. Events bubble up so you'll be&lt;br /&gt;able to catch the event and figure out which button it originated from. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;You also don't need to wait for the &lt;span class=SpellE&gt;onload&lt;/span&gt;&lt;br /&gt;event in order to start doing something with the DOM tree. Often all you need&lt;br /&gt;is the element you want to access to be available in the tree. You don't have&lt;br /&gt;to wait for all images to be downloaded. &lt;span class=SpellE&gt;DOMContentLoaded&lt;/span&gt;&lt;br /&gt;is the event you might consider using instead of &lt;span class=SpellE&gt;&lt;span&lt;br /&gt;class=GramE&gt;onload&lt;/span&gt;&lt;/span&gt;, but until it's available in all browsers, you&lt;br /&gt;can use the YUI Event utility, which has an &lt;span class=SpellE&gt;onAvailable&lt;/span&gt;&lt;br /&gt;method. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For more information check the YUI theatre's &amp;quot;High&lt;br /&gt;Performance Ajax Applications&amp;quot; by &lt;span class=SpellE&gt;Julien&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;Lecomte&lt;/span&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Choose&lt;br /&gt;&amp;lt;link&amp;gt; over @import&lt;/u&gt;&lt;/b&gt;: css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;One of the previous best practices states that CSS should be&lt;br /&gt;at the top in order to allow for progressive rendering. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;In IE @import behaves the same as using &amp;lt;link&amp;gt; at the&lt;br /&gt;bottom of the page, so it's best not to use it. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Avoid Filters&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;css&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The IE-proprietary &lt;span class=SpellE&gt;AlphaImageLoader&lt;/span&gt;&lt;br /&gt;filter aims to fix a problem with semi-transparent true color &lt;span&lt;br /&gt;class=SpellE&gt;PNGs&lt;/span&gt; in IE versions &amp;lt; 7. The problem with this filter is&lt;br /&gt;that it blocks rendering and freezes the browser while the image is being&lt;br /&gt;downloaded. It also increases memory consumption and is applied per element,&lt;br /&gt;not per image, so the problem is multiplied. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The best approach is to avoid &lt;span class=SpellE&gt;AlphaImageLoader&lt;/span&gt;&lt;br /&gt;completely and use gracefully degrading PNG8 instead, which are fine in IE. If&lt;br /&gt;you absolutely need &lt;span class=SpellE&gt;AlphaImageLoader&lt;/span&gt;, use the&lt;br /&gt;underscore hack _filter as to not penalize your IE7+ users. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Optimize Images&lt;/u&gt;&lt;/b&gt;:&lt;br /&gt;images&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;After a designer is done with creating the images for your&lt;br /&gt;web page, there are still some things you can try before you FTP those images&lt;br /&gt;to your web server. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;You can check the &lt;span class=SpellE&gt;GIFs&lt;/span&gt; and see if&lt;br /&gt;they are using a palette size corresponding to the number of colors in the&lt;br /&gt;image. Using &lt;span class=SpellE&gt;imagemagick&lt;/span&gt; it's easy to check using &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;identify&lt;/span&gt; -verbose &lt;span&lt;br /&gt;class=SpellE&gt;image.gif&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;When you see an image &lt;span class=SpellE&gt;useing&lt;/span&gt; 4&lt;br /&gt;colors and a 256 color &amp;quot;slots&amp;quot; in the palette, there is room for&lt;br /&gt;improvement. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Try converting &lt;span class=SpellE&gt;GIFs&lt;/span&gt; to &lt;span&lt;br /&gt;class=SpellE&gt;PNGs&lt;/span&gt; and see if there is a saving. More often than not,&lt;br /&gt;there is. Developers often hesitate to use &lt;span class=SpellE&gt;PNGs&lt;/span&gt; due&lt;br /&gt;to the limited support in browsers, but this is now a thing of the past. The&lt;br /&gt;only real problem is alpha-transparency in true color &lt;span class=SpellE&gt;PNGs&lt;/span&gt;,&lt;br /&gt;but then again, &lt;span class=SpellE&gt;GIFs&lt;/span&gt; are not true color and don't&lt;br /&gt;support variable transparency either. So anything a GIF can do, a palette PNG&lt;br /&gt;(PNG8) can do too (except for animations). This simple &lt;span class=SpellE&gt;imagemagick&lt;/span&gt;&lt;br /&gt;command results in totally safe-to-use &lt;span class=SpellE&gt;PNGs&lt;/span&gt;:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;convert&lt;/span&gt; &lt;span class=SpellE&gt;image.gif&lt;/span&gt;&lt;br /&gt;&lt;span class=SpellE&gt;image.png&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&amp;quot;All we are saying is: Give &lt;span class=SpellE&gt;PiNG&lt;/span&gt;&lt;br /&gt;a Chance!&amp;quot; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Run &lt;span class=SpellE&gt;pngcrush&lt;/span&gt; (or any other PNG&lt;br /&gt;optimizer tool) on all your &lt;span class=SpellE&gt;PNGs&lt;/span&gt;. Example: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;&lt;span class=GramE&gt;pngcrush&lt;/span&gt;&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;image.png&lt;/span&gt; -&lt;span class=SpellE&gt;rem&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;alla&lt;/span&gt; -reduce -brute &lt;span class=SpellE&gt;result.png&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Run &lt;span class=SpellE&gt;jpegtran&lt;/span&gt; on all your JPEGs.&lt;br /&gt;This tool does lossless JPEG operations such as rotation and can also be used&lt;br /&gt;to optimize and remove comments and other useless information (such as EXIF&lt;br /&gt;information) from your images. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;&lt;span class=GramE&gt;jpegtran&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;-copy none -optimize -perfect &lt;span class=SpellE&gt;src.jpg&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;dest.jpg&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Optimize CSS &lt;span&lt;br /&gt;class=GramE&gt;Sprites&lt;span style='font-weight:normal;text-decoration:none;&lt;br /&gt;text-underline:none'&gt; :&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt; images&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;Arranging the images in the sprite&lt;br /&gt;horizontally as opposed to vertically usually results in a smaller file size.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Combining similar colors in a sprite helps you keep the&lt;br /&gt;color count low, ideally under 256 colors so to fit in a PNG8. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&amp;quot;Be mobile-friendly&amp;quot; and don't leave big gaps&lt;br /&gt;between the images in a sprite. This doesn't affect the file size as much but&lt;br /&gt;requires less memory for the user agent to decompress the image into a pixel&lt;br /&gt;map. 100x100 &lt;span class=GramE&gt;image&lt;/span&gt; is 10 thousand pixels, where&lt;br /&gt;1000x1000 is 1 million pixels &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Don't Scale Images&lt;br /&gt;in HTML&lt;/u&gt;&lt;/b&gt;: images&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Don't use a bigger image than you need just because you can&lt;br /&gt;set the width and height in HTML. If you need &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&amp;lt;&lt;span class=SpellE&gt;img&lt;/span&gt; width=&amp;quot;100&amp;quot;&lt;br /&gt;height=&amp;quot;100&amp;quot; &lt;span class=SpellE&gt;src&lt;/span&gt;=&amp;quot;&lt;span class=SpellE&gt;mycat.jpg&lt;/span&gt;&amp;quot;&lt;br /&gt;alt=&amp;quot;My Cat&amp;quot; /&amp;gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=GramE&gt;then&lt;/span&gt; your image (&lt;span&lt;br /&gt;class=SpellE&gt;mycat.jpg&lt;/span&gt;) should be 100x100px rather than a scaled down&lt;br /&gt;500x500px image. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Make &lt;span&lt;br /&gt;class=SpellE&gt;favicon.ico&lt;/span&gt; Small and Cacheable&lt;/u&gt;&lt;/b&gt;: images&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;The &lt;span class=SpellE&gt;favicon.ico&lt;/span&gt; is an image that&lt;br /&gt;stays in the root of your server. It's a necessary evil because even if you&lt;br /&gt;don't care about it the browser will still request it, so it's better not to&lt;br /&gt;respond with a 404 Not Found. Also since it's on the same server, cookies are&lt;br /&gt;sent every time it's requested. This image also interferes with the download&lt;br /&gt;sequence, for example in IE when you request extra components in the &lt;span&lt;br /&gt;class=SpellE&gt;&lt;span class=GramE&gt;onload&lt;/span&gt;&lt;/span&gt;&lt;span class=GramE&gt;,&lt;/span&gt;&lt;br /&gt;the &lt;span class=SpellE&gt;favicon&lt;/span&gt; will be downloaded before these extra&lt;br /&gt;components. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;So to mitigate the drawbacks of having a &lt;span class=SpellE&gt;favicon.ico&lt;/span&gt;&lt;br /&gt;make sure: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;It's small, preferably under 1K. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Set Expires header with what you feel comfortable (since you&lt;br /&gt;cannot rename it if you decide to change it). You can probably safely set the&lt;br /&gt;Expires header a few months in the future. You can check the last modified date&lt;br /&gt;of your current &lt;span class=SpellE&gt;favicon.ico&lt;/span&gt; to make an informed&lt;br /&gt;decision. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;span class=SpellE&gt;Imagemagick&lt;/span&gt; can help you create&lt;br /&gt;small &lt;span class=SpellE&gt;favicons&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Keep Components&lt;br /&gt;under 25K&lt;/u&gt;&lt;/b&gt;: mobile&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;This restriction is related to the fact that &lt;span&lt;br /&gt;class=SpellE&gt;iPhone&lt;/span&gt; won't cache components bigger than 25K. Note that&lt;br /&gt;this is the uncompressed size. This is where &lt;span class=SpellE&gt;minification&lt;/span&gt;&lt;br /&gt;is important because gzip alone may not be sufficient. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;For more information check &amp;quot;Performance Research, Part&lt;br /&gt;5: &lt;span class=SpellE&gt;iPhone&lt;/span&gt; &lt;span class=SpellE&gt;Cacheability&lt;/span&gt; -&lt;br /&gt;Making it Stick&amp;quot; by Wayne Shea and &lt;span class=SpellE&gt;Tenni&lt;/span&gt; &lt;span&lt;br /&gt;class=SpellE&gt;Theurer&lt;/span&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;b style='mso-bidi-font-weight:normal'&gt;&lt;u&gt;Pack Components&lt;br /&gt;into a Multipart Document&lt;/u&gt;&lt;/b&gt;: mobile&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;Packing components into a multipart document is like an&lt;br /&gt;email with attachments, it helps you fetch several components with one HTTP&lt;br /&gt;request (remember: HTTP requests are expensive). When you use this technique,&lt;br /&gt;first check if the user agent supports it (&lt;span class=SpellE&gt;iPhone&lt;/span&gt;&lt;br /&gt;does not). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-6767943512160513016?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.blogger.com/post-delete.g?blogID=5127893340841894477&amp;postID=6767943512160513016' title='Wesite performance Tips'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/6767943512160513016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/6767943512160513016'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/11/wesite-performance-tips.html' title='Wesite performance Tips'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-2438694406400139428</id><published>2008-10-14T11:05:00.002+05:30</published><updated>2008-10-14T11:08:29.075+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><title type='text'>Access Modifier in C#</title><content type='html'>Well the access modifier are the reserve keywords which define the access right and scope of access the entity.Objects in .NET are created from a class, struct, etc.  These definitions, as well as the properties, methods, or events within them, use an access modifer that determines who can access it.  A class or structure outside of the current class definition or even the in different projects have different access rights depending on the type of accessor used.  Take a look at the accessors below:&lt;br /&gt;public&lt;br /&gt;This makes the member visible globally&lt;br /&gt;Eg. class Gremlin { public Gremlin spawn() { return new Gremlin(); } } &lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;protected&lt;/span&gt;&lt;br /&gt;This makes the member visible to the current class and to child classes.  Protected members are only accessible in the same class or through inherited classes.&lt;br /&gt;Eg. class ParentClass { protected int valueA; }&lt;br /&gt;class ChildClass { public void doSomething() { valueA = 3; } }&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;private&lt;/span&gt;&lt;br /&gt;This makes the member visible only to the current class.&lt;br /&gt;Eg. class MyCollection { private int lastIndex; }&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;internal / Friend&lt;/span&gt;&lt;br /&gt;This makes the member visible within the same assembly.&lt;br /&gt;Eg. internal class ProprietaryStuff { } &lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;protected internal / Protected Friend&lt;/span&gt;&lt;br /&gt;A combination of protected and internal.  This makes the member visible within the same assembly and also makes the member visible to an inheriting class. An inheriting class does not need to be in the same assembly to access the member.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-2438694406400139428?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://dotnetarmy.blogspot.com/2008/10/access-modifier.html' title='Access Modifier in C#'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/2438694406400139428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/2438694406400139428'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/10/access-modifier.html' title='Access Modifier in C#'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-8160828055440974037</id><published>2008-09-30T16:59:00.007+05:30</published><updated>2008-09-30T17:17:54.412+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Known Errors'/><title type='text'>Could not load file or assembly … The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)</title><content type='html'>This error usually come when the power off suddenly and the v studio unable to make signature of some library.&lt;br /&gt;&lt;br /&gt;The solution is simple : You have to delete the Temporary ASP.NET Files&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step to Follow&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 1 ::-&gt;&lt;/span&gt; Open File Explorer.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 2 ::-&gt; &lt;/span&gt;Go To Windows Foler&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 3 ::-&gt;&lt;/span&gt; Go To Framework Folder&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 4 ::-&gt;&lt;/span&gt; Open "Temporary ASP.NET Files" Folder&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 5 ::-&gt;&lt;/span&gt; Select all file or if you remember the project you are working on then delete the specific files only for that project&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ur are done :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sample Path&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span style="font-style:italic;"&gt;Happy Programming&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-8160828055440974037?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://dotnetarmy.blogspot.com/2008/09/could-not-load-file-or-assembly.html' title='Could not load file or assembly … The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/8160828055440974037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/8160828055440974037'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/09/could-not-load-file-or-assembly.html' title='Could not load file or assembly … The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-4992353907493974722</id><published>2008-08-18T13:03:00.004+05:30</published><updated>2008-08-18T13:06:41.738+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Downloading file from a URL/Open Save dialog in downloading file</title><content type='html'>Some time you need to download the file from the URL then follwing code can help u out.&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;   &lt;span style="font-weight:bold;"&gt; private void downloadURL(string fileURL)&lt;br /&gt;    {&lt;/span&gt;&lt;br /&gt;        //::-&gt;STEP&lt;br /&gt;        //::-&gt;Step -1 :::-&gt;Get filename        &lt;br /&gt;        //::-&gt;Step -2 :::-&gt;Adding Headeres&lt;br /&gt;        //::-&gt;Step -3 :::-&gt;Set the Content Type&lt;br /&gt;        //::-&gt;Step -4 :::-&gt;Tansmit the file&lt;br /&gt;        //::-&gt;Step -5 :::-&gt;End of the Response&lt;br /&gt;&lt;br /&gt;        string name = Path.GetFileName(fileURL);&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;// ::-&gt;Get filename    &lt;/span&gt;    &lt;br /&gt;        string fileName = Path.GetFileName(fileURL);&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;// ::-&gt; Adding Headeres&lt;/span&gt;&lt;br /&gt;        Response.AddHeader("Content-disposition", "attachment; filename=" +  fileName);&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;//::-&gt; Set the Content Type&lt;/span&gt;&lt;br /&gt;        Response.ContentType = "application/octet-stream";&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-weight:bold;"&gt; //::-&gt; Tansmit the file&lt;/span&gt;&lt;br /&gt;        Response.TransmitFile(fileURL);&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;//::-&gt; End of the Response&lt;/span&gt;&lt;br /&gt;        Response.End();&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight:bold;"&gt;}  &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-4992353907493974722?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4992353907493974722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4992353907493974722'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/08/downloading-file-from-urlopen-save.html' title='Downloading file from a URL/Open Save dialog in downloading file'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-818376547240165506</id><published>2008-08-18T12:45:00.004+05:30</published><updated>2008-08-18T12:49:16.148+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Gridview excel export</title><content type='html'>Some time we have a requirement that we need to export our gridview into the excelsheet.Me have the same requirement so  I resolved it as ,I take a image button on the right top of the gridview and on the click of the button I write the following function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;protected void imgBtnExcelExport_Click(object sender, ImageClickEventArgs e)&lt;br /&gt;   {&lt;/span&gt;&lt;br /&gt;        string TempString = string.Empty;&lt;br /&gt;        string TempOutput = string.Empty;&lt;br /&gt;        Response.Clear();&lt;br /&gt;       &lt;span style="font-weight:bold;"&gt;// ::-&gt; Adding the Header&lt;/span&gt;&lt;br /&gt;       Response.AddHeader("content-disposition", "attachment;filename=" + this.ReportTitle.Text.Replace(" - "," ").Replace(" ","_").ToString().Trim() + ".xls");&lt;br /&gt;        Response.Charset = "";       &lt;br /&gt;        Response.ContentType = "application/vnd.ms-excel";       &lt;br /&gt;&lt;br /&gt;       &lt;span style="font-weight:bold;"&gt; // ::-&gt; Create Stream Write object&lt;/span&gt;&lt;br /&gt;        System.IO.StringWriter stringWrite = new System.IO.StringWriter();&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-weight:bold;"&gt; // ::-&gt; Render controls&lt;/span&gt;&lt;br /&gt;        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);&lt;br /&gt;        System.Web.UI.HtmlTextWriter htmlWritelbl = new HtmlTextWriter(stringWrite);&lt;br /&gt;        System.Web.UI.HtmlTextWriter htmlWriteImgLegend = new HtmlTextWriter(stringWrite);&lt;br /&gt;        this.ReportTitle.RenderControl(htmlWritelbl);&lt;br /&gt;        this.dgReport.RenderControl(htmlWrite);&lt;br /&gt;        this.ImgLegend.RenderControl(htmlWriteImgLegend);      &lt;br /&gt;        Response.Write(stringWrite.ToString();   );&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;Response.End();&lt;/span&gt;&lt;br /&gt;    &lt;span style="font-weight:bold;"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-818376547240165506?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/818376547240165506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/818376547240165506'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/08/gridview-excel-export.html' title='Gridview excel export'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-3070575551107117199</id><published>2008-08-12T12:13:00.004+05:30</published><updated>2008-08-14T17:46:08.431+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sports'/><title type='text'>Gold Medal By Abhinav</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_910U8onGAxQ/SKE3egWKFdI/AAAAAAAAAD4/Mj8KZNol4x8/s1600-h/photo.cms.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_910U8onGAxQ/SKE3egWKFdI/AAAAAAAAAD4/Mj8KZNol4x8/s320/photo.cms.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5233525239199700434" /&gt;&lt;/a&gt;&lt;br /&gt;Congratulation to all Indians,&lt;br /&gt;&lt;br /&gt;                      Really the magical moments when abhinav shots the magical shot by his magical rifle and get the gold medal put the stone in the history and all Indian were happy iam too as iam Indian but suddenly i feel one more type of frustrating happiness by thinking that iam a 26 year old guy fond of sports with a true nationalism with sport spirit but dint find any such moment ,why? the Olympic is such a execution happen after every 4 year but we don't have any gold ,why why why ?&lt;br /&gt;&lt;br /&gt;              This makes me more frustrating then happy that is why i used the word "magical" because this shows like a magic ,salutes to the Concentration of Abhinav and thank to make me feel like the winning of &lt;br /&gt;&lt;br /&gt;GOLD.&lt;br /&gt;&lt;br /&gt;            It is not that other participant are not willing to win gold they want GOLD they dream about GOLD and they put their 101% efforts but their 101% is not sufficient to win GOLD because we don't have the persons who can tell us what percent of our effort makes us to win the gold so to feel this kind of happiness again and again ,twice a day thrice a day we should have that person called coach.&lt;br /&gt;&lt;br /&gt;        The conclusion is that we should hire the best coach for out participant,&lt;br /&gt;And I also respect the feelings of all the donor who gave a handsome amount as a prize to the winning the participant but i also request you if u believe any of the candidate prior for going to fight for GOLD and give him only the half of the amount so that he can do a preparation for his/her worship then i am sure we are going to feel this kind of happiness 5 times a day whole week during the Olympics.&lt;br /&gt;&lt;br /&gt;One again a Salute to INDIAN HERO ABHINAV&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-3070575551107117199?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/3070575551107117199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/3070575551107117199'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/08/gold-medal-by-abhinav.html' title='Gold Medal By Abhinav'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_910U8onGAxQ/SKE3egWKFdI/AAAAAAAAAD4/Mj8KZNol4x8/s72-c/photo.cms.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-4153302387052146107</id><published>2008-06-16T14:19:00.002+05:30</published><updated>2008-08-18T12:52:25.809+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Understanding the JavaScript __doPostBack Function</title><content type='html'>In this article we going to understand the the functionality of  __doPostBack function of JavaScript. &lt;br /&gt;&lt;br /&gt;_doPostBack Function&lt;br /&gt;Let us take a look at the function. &lt;br /&gt;Listing 1 - _The __doPostBack function&lt;br /&gt;&lt;input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /&gt;&lt;br /&gt;&lt;input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /&gt;&lt;br /&gt;function __doPostBack(eventTarget, eventArgument) {&lt;br /&gt;if (!theForm.onsubmit || (theForm.onsubmit() != false)) {&lt;br /&gt;theForm.__EVENTTARGET.value = eventTarget;&lt;br /&gt;theForm.__EVENTARGUMENT.value = eventArgument;&lt;br /&gt;theForm.submit();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;Description&lt;br /&gt;The __doPostBack function takes two arguments, eventTarget and eventArgument.  The eventTarget contains the ID of the control that causes the postback and the eventArgument contains any additional data associated with the control.  Note that the two hidden fields, “__EVENTTARGET” and “__EVENTARGUMENT,” are automatically declared.  The value of the eventTarget and eventArgument are stored in the hidden fields.  The two hidden variables can be accessed from the code behind using the forms/params collection.   &lt;br /&gt;Using the hidden variables you can also find the ID of the control which causes the postback.  All you need to do is to retrieve the value of the __EVENTTARGET from the form parameter collection.  Take a look at the code below. &lt;br /&gt;Listing 2 – Getting the _EVENTTARGET hidden field&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;  string controlName = Request.Params.Get("__EVENTTARGET");&lt;br /&gt;}&lt;br /&gt;Description&lt;br /&gt;For this code to work you need to add any web server control on the form except for Button and ImageButton control (Discuss it later).  Let us add the DropDownList control and set the AutoPostBack property to true and populate the DropDownList with some dummy data.  Now, run the page and view the source of the page. &lt;br /&gt;You will see the following line of code.&lt;br /&gt;Listing 3 – DropDownList calling __doPostBack function&lt;br /&gt;&lt;select name="DropDownList1" &lt;br /&gt;onchange="javascript:setTimeout('__doPostBack(\'DropDownList1\',\'\')', 0)"&lt;br /&gt; id="DropDownList1"&gt;&lt;br /&gt;&lt;option selected="selected" value="One"&gt;One&lt;/option&gt;&lt;br /&gt;&lt;option value="Two"&gt;Two&lt;/option&gt;&lt;br /&gt;&lt;/select&gt;&lt;br /&gt;The onchange event of the DropDownList calls the __doPostBack function.  The ID of the control, “DropDownList1,” is also passed to the _doPostBack function and stored in the _EVENTTARGET hidden field.  In the Page_Load I fetch the value of the _EVENTTARGET variable which in this case is the ID of the DropDownList.   This way we can find out that which control caused the postback. &lt;br /&gt;What about Buttons and ImageButtons?&lt;br /&gt;You might be wondering about the POSTBACK triggered by the Buttons and the ImageButtons. Well, let us see the code generated by the Buttons. &lt;br /&gt;Listing 4 – Code generated by the Button server control&lt;br /&gt;&lt;input type="submit" name="Button1" value="Do PostBack" id="Button1" /&gt;&lt;br /&gt;As demonstrated in the code above, the Button control does not call the __doPostBack function. Because of this, the _EVENTTARGET will always be empty.  However, you can find out the ID of the Button by looping through the form controls collection.  Take a look at the code below. &lt;br /&gt;Listing 5 – Finding the Button control in the form collection&lt;br /&gt;foreach (string str in Request.Form)&lt;br /&gt;{&lt;br /&gt;  Control c = Page.FindControl(str);&lt;br /&gt;  if (c is Button)&lt;br /&gt;  {&lt;br /&gt;    control = c;&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;Description&lt;br /&gt;In the code above I iterated through the controls on the page.  If the control is of type Button then the loop breaks and the control is returned back to the user. &lt;br /&gt;Passing Arguments&lt;br /&gt;If you look closely at the __doPostBack function you will notice that the second argument is called the eventArgument.  You can allow controls to pass arguments to the doPostBack function.  Check out the code below. &lt;br /&gt;Listing 6 – Passing arguments to the __doPostBack function&lt;br /&gt;&lt;input type="button" id="Button2" value="Press me" onclick="DoPostBack()" /&gt;&lt;br /&gt;&lt;script language="javascript" type="text/javascript"&gt;&lt;br /&gt; &lt;br /&gt;function DoPostBack() &lt;br /&gt;{&lt;br /&gt;  __doPostBack('Button2','My Argument');     &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;&lt;/script&gt;&lt;br /&gt;string passedArgument = Request.Params.Get("__EVENTARGUMENT");&lt;br /&gt;Description&lt;br /&gt;The “Button2” when clicked fires the DoPostBack function which in turn calls the __doPostBack.  The __doPostBack function contains two arguments, eventTarget and eventArgument.  The eventTarget is “Button2” and the eventArgument is “My Argument.”  Later, in the C# code behind, I have accessed the eventArgument using the Request.Params collection.  The passedArgument variable will contain the value “My Argument.”&lt;br /&gt;Thanks to aspalliance.com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-4153302387052146107?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4153302387052146107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/4153302387052146107'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/06/understanding-javascript-dopostback.html' title='Understanding the JavaScript __doPostBack Function'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-1948213688862137555</id><published>2008-06-10T16:56:00.001+05:30</published><updated>2008-08-18T12:51:33.116+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Add Grouped / Multiple row Header in the GridView</title><content type='html'>GridView the awesome control of the dot net is made so extendable that you can achive most thing you can thought about ,recently i&lt;br /&gt;&lt;br /&gt;got the requirement that i have to show multiple row header in my application so i do some rearch and go a very simple solution.&lt;br /&gt;&lt;br /&gt;Here we go.&lt;br /&gt;&lt;br /&gt;What You have to do is just write some line of the code in the gridview RowDataBound event like&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;protected void GridViewData_RowDataBound(object sender, GridViewRowEventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        SortedList FormatCells = new SortedList();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        FormatCells.Add("1", ",1,2");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        FormatCells.Add("2", "TopGroup,4,1");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        SortedList FormatCells2 = new SortedList();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        FormatCells2 .Add("1", "Subgroup1,2,1");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        FormatCells2 .Add("2", ""Subgroup2,1,1");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        GetMultiRowHeader(e, FormatCells2 );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        GetMultiRowHeader(e, FormatCells );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And Here is the function&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;public void GetMultiRowHeader(GridViewRowEventArgs e, SortedList GetCels)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        if (e.Row.RowType == DataControlRowType.Header)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            GridViewRow row;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            IDictionaryEnumerator enumCels = GetCels.GetEnumerator();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            row = new GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            while (enumCels.MoveNext())&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                string[] count = enumCels.Value.ToString().Split(Convert.ToChar(","));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                TableCell Cell;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell = new TableCell();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell.RowSpan = Convert.ToInt16(count [2].ToString());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell.ColumnSpan = Convert.ToInt16(count [1].ToString());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell.Controls.Add(new LiteralControl(count [0].ToString()));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell.HorizontalAlign = HorizontalAlign.Center;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                Cell.ForeColor = System.Drawing.Color.White;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                row.Cells.Add(Cell);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            e.Row.Parent.Controls.AddAt(0, row);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    }   &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-1948213688862137555?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1948213688862137555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1948213688862137555'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/06/add-grouped-multiple-row-header-in.html' title='Add Grouped / Multiple row Header in the GridView'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-1142094427681920364</id><published>2008-06-03T20:52:00.010+05:30</published><updated>2008-11-13T09:15:58.866+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><title type='text'>Magic Of References</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;div&gt;"If C# manipulates objects by reference, will a swap work?" - This issue must certainly have troubled quiet a lot of beginners. C# does manipulate objects by reference, and all object variables are references. On the other hand, C# does not pass method arguments by reference; it passes them by value, (even if the method arguments are of reference type). Thus, a regular swap method will not work! Let's come from the beginning, we know that there are four kinds of formal parameters in a C# method declaration, namely Value parameters, which are declared without any modifiers. (default) Reference parameters, which are declared with the ref modifier. Output parameters, which are declared with the out modifier. Parameter arrays, which are declared with the params modifier. Thus if there is no any method parameter keyword (ref or out), the parameter can have a value associated with it. That value can be changed in the method, but that value will not be reflected when the control passes back to the calling procedure. This is true for all value types. Now, consider a reference type, an object. If we pass an object to a method and if the value of its member is changed, it will be retained even when the control is passed back to the calling procedure! This is because objects are manipulated by reference. If so, then, if we pass two objects to a regular swap method and come back to the calling procedure to see whether they have got swapped, they would have not! Look down the code below,&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_910U8onGAxQ/SEVihUtJ6wI/AAAAAAAAACM/6TLxcU_8z2M/s1600-h/Region+Capture.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5207676868757154562" style="CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_910U8onGAxQ/SEVihUtJ6wI/AAAAAAAAACM/6TLxcU_8z2M/s320/Region+Capture.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The out put is as follows&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;img id="BLOGGER_PHOTO_ID_5207677565381124994" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_910U8onGAxQ/SEVjJ31QI4I/AAAAAAAAACc/Tiu0sSmgjOM/s320/Region+Capture.jpg" border="0" /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;In the above program, we pass the instances obj1 and obj2 of class1 to badswap_noref() method and see that they are not actually getting swapped. This is what actually happens in the badswap_noref method. Not the actual references obj1 and obj2 are passed. But a copy of the references is passed. So param1 and param2 contains a copy of the actual references obj1 and obj2 respectively. We are able to modify the values of X and Y in the badswap_noref method thru param1 and param2, because param1 and param2 still points to the same address locations referred to by obj1 and obj2. But what we are swapping is only param1 and param2, the method references, which are not retained when we come back to the calling procedure, Main().&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5207677952390352610" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_910U8onGAxQ/SEVjgZjcTuI/AAAAAAAAACk/4bmStYjfJOI/s320/Region+Capture.jpg" border="0" /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5207678376111977634" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_910U8onGAxQ/SEVj5ECjNKI/AAAAAAAAACs/QWsr-cOKbFk/s320/Region+Capture.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;Thus, in C#, a swap method can be made possible by using the ref keyword. In such a case, we pass the object references explicitly by reference and not by value, thus able to swap them right in the called method.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;img id="BLOGGER_PHOTO_ID_5207678686729304114" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_910U8onGAxQ/SEVkLJLfeDI/AAAAAAAAAC0/5gYo-AJVFag/s320/Region+Capture.jpg" border="0" /&gt;  &lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt; &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;thanks to &lt;/div&gt;&lt;div&gt;&lt;a href="http://www.c-sharpcorner.com/UploadFile/saragana/Willswapwork11162005012542AM/Willswapwork.aspx"&gt;http://www.c-sharpcorner.com/UploadFile/saragana/Willswapwork11162005012542AM/Willswapwork.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-1142094427681920364?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1142094427681920364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1142094427681920364'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/06/magic-of-references.html' title='Magic Of References'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_910U8onGAxQ/SEVihUtJ6wI/AAAAAAAAACM/6TLxcU_8z2M/s72-c/Region+Capture.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-765946070231886157</id><published>2008-05-16T14:44:00.002+05:30</published><updated>2008-08-18T12:54:38.881+05:30</updated><title type='text'>GridView Paging Style</title><content type='html'>&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="grdCustomers"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cssclass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="blackborder"&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(255, 0, 0);"&gt;CellPadding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="3"&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(255, 0, 0);"&gt;style&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;:&lt;span style="color: rgb(0, 0, 255);"&gt;800px&lt;/span&gt;;&lt;span style="color: rgb(0, 0, 255);"&gt;"&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(255, 0, 0);"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="false"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;onrowcommand&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="grdCustomers_RowCommand"&lt;/span&gt; &lt;br /&gt;&lt;strong&gt;        &lt;span style="color: rgb(255, 0, 0);"&gt;PageSize&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="4"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;AllowPaging&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;onpageindexchanging&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;strong&gt;="grdCustomers_PageIndexChanging"&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;        &lt;span style="color: rgb(255, 0, 0);"&gt;PagerSettings-Mode&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="NumericFirstLast"&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(255, 0, 0);"&gt;PagerSettings-PageButtonCount&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="10"&lt;/span&gt;                                        &lt;br /&gt;&lt;/strong&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;AlternatingRowStyle&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;CssClass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="gridalternate"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;HeaderStyle&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;CssClass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="gridheader"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;PagerStyle&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cssClass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="gridpager"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Right"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;/span&gt; &lt;br /&gt;&lt;/strong&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SelectedRowStyle&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;BackColor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="teal"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;HyperLinkField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataTextField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Company"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Company"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataNavigateUrlFields&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Pk"&lt;/span&gt;&lt;br /&gt;                           &lt;span style="color: rgb(255, 0, 0);"&gt;DataNavigateUrlFormatString&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ShowCustomer.aspx?id={0}"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;BoundField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Name"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Name"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;BoundField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="LastOrder"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Last Order"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Action"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ItemStyle-HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="center"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ItemStyle-Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="70px"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;LinkButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;CommandName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="DeleteCustomer"&lt;/span&gt;&lt;br /&gt;                               &lt;span style="color: rgb(255, 0, 0);"&gt;CommandArgument&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;='&lt;/span&gt;&lt;span style="background: rgb(255, 238, 98) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Eval("pk") &lt;span style="background: rgb(255, 238, 98) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;'&lt;br /&gt;&lt;/span&gt;                                &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Delete"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;LinkButton&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;                   &lt;br /&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;                     &lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt; &lt;p&gt;I use a pager style which is defined something like this in a CSS stylesheet:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.gridpager, .gridpager td&lt;br /&gt;&lt;/span&gt;{   &lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;text-align&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;right&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;color&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;cornsilk&lt;/span&gt;;   &lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;font-weight&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;bold&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;text-decoration&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;none&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.gridpager&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;a&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;&lt;/span&gt;{&lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;color&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;White&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: rgb(255, 0, 0);"&gt;font-weight&lt;/span&gt;: &lt;span style="color: rgb(0, 0, 255);"&gt;normal&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-765946070231886157?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/765946070231886157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/765946070231886157'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2008/05/gridview-paging-style.html' title='GridView Paging Style'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-5127893340841894477.post-1679134594884213202</id><published>2007-10-27T00:21:00.002+05:30</published><updated>2008-08-18T12:53:14.222+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><title type='text'>Object oriented programming and Classes</title><content type='html'>lThink of Classes as being Template&lt;br /&gt;lClasses ENCAPSULATE&lt;br /&gt;–Data&lt;br /&gt;–Behavior (i.e. Management of Data)&lt;br /&gt;In One Location&lt;br /&gt;Some More Definitions of Class&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;lIn Real world ,a class is a group of similar type of Objects.&lt;br /&gt;lIn object oriented programming, a class is a template definition of the methods and variable in a particular kind of object.&lt;br /&gt;la class is a programming language construct used to group related instance variables and methods.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;lObjects are the fundamental program units of object-oriented programs.&lt;br /&gt;lAn object is a specific instance of a class, it contains real values instead of variables.&lt;br /&gt;lA typical object bundles together both data( also known as state) and behavior.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Object's state ::-&gt;&lt;br /&gt;An object's state consists of values assigned to a set of properties within the object.&lt;br /&gt;Object's behavior ::-&gt;&lt;br /&gt;An object's behavior is created by a set of methods, also known as functions or routines, defined within the object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following diagram represents a simple Contact object .&lt;br /&gt;Specifically, it contains a name and a contact type: “Smith,John”, “Business”.&lt;br /&gt;The object also contains a method named DisplayInfo that outputs the values of the Name and ContactType properties.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;lClass&lt;br /&gt;A class is an object maker: it contains all the statements needed to create an object, its attributes, as well as the statements to describe the operations that the object will be able to perform.&lt;br /&gt;lIn object-oriented programming, a class can indeed also be a member of a set of classes organized in a hierarchy. This aspect will be introduced later through the concept of inheritance. But for now, we will use the term class as just a maker of objects, or an object factory.&lt;br /&gt;lHaving a class defined, you can create as many objects as needed. These objects are called instances of this class. All the instances created with a given class will have the same structure and behaviour. They will only differ regarding their state, i.e regarding the value of their attributes. Namely, names and sequences will not be the same for all sequences objects that will be created.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5127893340841894477-1679134594884213202?l=dotnetarmy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1679134594884213202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5127893340841894477/posts/default/1679134594884213202'/><link rel='alternate' type='text/html' href='http://dotnetarmy.blogspot.com/2007/10/blog-post.html' title='Object oriented programming and Classes'/><author><name>Spanco</name><uri>http://www.blogger.com/profile/06893489750282819986</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_910U8onGAxQ/SnhSUaaBWhI/AAAAAAAABO4/uZePP8vuq4Y/S220/IAM.jpg'/></author></entry></feed>
