ImageHandler.cs / image.axd image caching

Jul 22, 2009 at 9:16 PM

Has anyone tested this technique for serving and caching images at the ASP.NET level vs. letting IIS handle it?  Confidently caching images correctly is important since it can be a lot of bandwidth.  This technique:

 

context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetExpires(DateTime.Now.AddYears(1));

SetCacheability() maps to the "Cache-Control" header

SetExpires() maps to the "Expires" header.

When I tried this on my own the images did not cache.  Perhaps the addition of Utils.SetConditionalGetHeaders() in BlogEngine.NET is the missing key, but I'm just wondering what other people's experience has been with this?

Thanks!