Minification and Consolidation
Another great way to reduce the number of requests needed to get a web page is to combine multiple small image files into a single larger file and use CSS to “index” into that larger image to show just the individual images you need for a web page. There are many tools available that can take a series of images, combine them into one, and even provide the necessary CSS styles to access each image. We were able to combine nearly half of the images on our home page into a single image.
Modern web pages also contain a large number of images. There are many ways to optimize image files to reduce their size via compression and other techniques. Most JPEG photo images can be reduced by 50% or more without any noticeable impact on image quality. Standard imaging programs like Photoshop provide built in mechanisms to compress JPEG images at various levels. Skeptics often doubt that this can be done without sacrificing image quality so I often create various images at different compression amounts, mix them up, and show them next to one another. People will be convinced that a given image looks better or worse than others, only to discover that when done properly they can rarely tell the difference in quality even though the file size is substantially smaller. Since image files are downloaded so often, simple optimization can not only improve performance for your users, but also reduce you bandwidth costs.
ASP.NET has always provided the Cache object which is great for storing data on the web server that does not change often. When converting our web site from ASP to ASP.NET we took advantage of the Cache to store just our products and category data. The ASP site would always query the database each time a user looked at a product detail page. The ASP.NET site would call the database just once each day, and would keep the results in the Cache object. This simple change cut 50% of all of our database queries, nearly 73,000,000 queries a month! Not only did that make the pages faster because they no longer had to wait for the database response, but the pages could not work even while the database was down.
Performance Testing Tools
YSlow and Google Page speed are two tools that can visit a web site and recommend changes that should be made to improve performance using standard techniques like those described above. They are very helpful for demonstrating what improvements should be made, and can help justify that they are proven industry best practice techniques to site stakeholders.
Learn more at DevWeek
Do these techniques seem interesting to you? Do you want to learn more about how they are implemented? I will be presenting “Improving Web Site Performance and Scalability While Saving Money” at DevWeek 2011 (http://www.devweek.com/) which will go into detail about these and many other techniques. Most of the techniques are free and simple to implement. Do you want to make your users and your boss happy at the same time? Sign up for the conference, stop by, and learn how to do both!