Filed under: Web Speed and Performance
The new caching features in ASP.NET are talked about a lot and that’s because .NET developers now have many features to take advantage of to improve the performance of their applications through server-side caching. Things like fragment caching and data caching along with their wide variety of configuration options, give developers all the tools they need to minimize expensive procedures in their dynamic pages, speeding up their applications.
But with all of the smart caching decisions that good .NET developers can make in developing their applications, there are some very easy caching related performance improvements that can be made by anyone with a Web site. And they’re not nearly as complex as server-side caching.
I’m referring to making your files cacheable in the end user’s browser cache. Since web applications serve much more than aspx files, most of them static ones like images and many css and large script files, there is no reason why these should be sent without the cache related HTTP headers to get these cached in the user’s browser.
Compared to the decisions that go into implementing ASP.NET server-side caching, devising a client-side page caching policy should be a cakewalk. It might make more sense for a system admin or a web site manager or whoever analyzes the web traffic to come up with the policy since they see which files are commonly requested and re-requested often. Maybe all of these people should contribute. This was actually a big consideration we had when we developed the
CacheRight tool. This tool uses a rules file to handle the cache control management of Web pages so that any of these people can 1) view the entire site-wide policy in one place and 2) manage that policy.
Even a loose and informal policy can make a huge difference. The most basic, yet beneficial, policy is simply to cache your images. The perceived benefit of this is always quite dramatic. Many people looking to improve their Web site’s performance through compression tools and expensive content distribution networks are often most impressed by simply doing this. When the images from your web site are displayed from a user’s cache, without the time delay of an unnecessary trip to your server to check whether the file has changed, they pop into view. When this happens it is noticeable–and with repeat visitors to your web site, this will happen. Ebay religiously uses cache control headers for its images. Outlook Web Access does too.
This isn’t low hanging fruit on the Low-cost Web Site Acceleration tree, this is more like a ripe 20 lb. watermelon that you step over every time you walk through the watermelon patch. There’s just no good reason for not taking advantage of this. It’s too easy. And this simple technique helps to solve many of the problems that send people in search of expensive Web acceleration solutions.
To illustrate, check the last-modified value of your site’s navigation images. They probably haven’t changed since your design firm created them for you more than a year ago. A year’s worth of conditional GET requests and the unnecessary connections opened to make those requests are wasteful when your users have copies in their cache. Just assign these images an expiry time of 24 hours and revisit your web site a couple of times. You’ll see the difference.No Comments »