How do I force IIS 7 to not cache images for a particular page?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In IIS7, you can do this either declaratively in your web.config, or programmatically.
The programmatic solution requires a simple HttpModule that’s registered to run for all requests in Integrated mode, where you look for the URLs that you’re concerned about. Then call:
FWIW, you may want to consider disabling client-side caching only, while enabling server-side caching, by using
HttpCacheability.ServerAndNoCache. Also, if you add a query string on the image names, you will prevent server-side caching by http.sys.In case it helps, I cover techniques like these in detail in my book: Ultra-Fast ASP.NET.