the "it's free" problem: caching of images

a long time ago journalists were paid for investigate in story's. Today content is almost free. Blogger's dominate the world. The problem is also if 99% of the information is true and useful, 1% is wrong and dangerous. I found the following free article in web which describes some issues with images and caching.

http://www.codeproject.com/KB/aspnet/CachingImagesInASPNET.aspx

The general caching topic is not easy, it depends on a lot of variables. But caching of images is solved in a quite nearly perfect matter with IIS 6.

The article suggest that you have to write instead of default handling a ashx handler. Then you add some header information in response and send image to client like:

Response.Cache.SetExpires(Date.Now.AddHours(3))

Response.Cache.SetCacheability(HttpCacheability.Public)

Response.Cache.SetValidUntilExpires(False)

Response.AddHeader("content-dispostion", "inline: default.aspx")

You can do that also with a aspx page, should be the same result.

in short word's: thats wrong! 

1) i would not suggest network monitor to watch http traffic. Tools like fiddler are specialized for that task

2) i would not reinvent the wheel. Caching of images is solved

3) i would not redirect requests through additional code, especially when the amount of request is high and you want to optimize performance

4) Caching should be done in a 200- 304 matter. Server must decided if newer information is available and send a 304 message or the new content with code 200

5) caching of sample page of the author doesn't work like fiddler shows

 

don?t believe anything- including this post ;-)

3 Comments

Comments have been disabled for this content.