Serving Dynamic Images

May 12, 2005

We noticed pretty quickly that the traffic logs for the Boerne Chamber of Commerce were a bit inflated. Upon closer inspection, I noticed that the images were constantly getting requested. What? Doesn't flash know how to cache images? Upon even closer inspection, I noticed that since the images were dynamically served, they weren't sending the correct headers. Apparently, the original author(s) of the ASP.Net Community Starter Kit forgot to add the basic headers required for HTTP Conditional GET requests. Certainly I'm no expert in this area, having picked up what I know from my RSS hacking days. It's amazing what a few added headers can do for your site's bandwidth. ASP.Net comes prepared with a few nice methods to aid in this quest: HttpRequest.Cache.SetETag and HttpRequest.Cache.SetLastModified. The moral of this story? Don't blame flash for everything? No, no. If you have any kind of dynamic content that doesn't change often, be sure to return the correct headers for browser caching. Especially for images and XML feeds.