Problem implementing ASP.NET response headers to force client-side image caching


I have created an ASP.NET IHttpHandler to serve images from a database. The handler works fine, but I am struggling to optimize it for clientside caching. I have followed the recommendations in the following article ...

While using Fiddler to monitor HTTP traffic, I can see that the headers have been correctly added to the response stream, exactly as described.

However, despite the caching headers, my browser is still requesting the images to be re-sent. This behavior is identical in IE7 and Firefox. I haven't changed the default caching configuration of either browser, so I can assume that I am seeing what the majority of my web visitors would see.

I have even added an additional "Expires" header to the response stream but, when refreshing a page containing the served images, the browser always sends a request with the "If-Modified-Since" header. Isn't it supposed to unconditionally use its own cached copy if the expiry period is still valid?

Any suggestions please?
Who is Participating?
SammyConnect With a Mentor Commented:
In case you dont know if you press F5 will cause any browser to ignore cache
one way to test this is to add a control on the page and have  it reload  the page to see if caching is working or not.

it would be more helpful if you post the code used for caching.

Good luck
Tim85Author Commented:

I can't believe it was that simple. I placed a Button control on the page and, when the page posts back to itself the client-side caching works perfectly.

However, I just checked the IE reference and it says that F5 refreshes the page and Ctrl+F5 refrreshes the page and the cache. Am I missing something?

Thanks again for helping me to see past my own stupidity.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.