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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.