"Nadav" <Na***@discussions.microsoft.com> wrote in message news:9E**********************************@microsof t.com...
How can I prevent the image from being cached?
What you describe sounds like the correct means of preventing caching by
the user agent, provided the user agent understands the header.
The only thing I'd check is that you're setting this on the correct HTTP re-
sponse, that is, the one generating the dynamic image (i.e., I presume else-
where in the same web control you're also setting the HTTP Content-Type
header to something like image/png or something.) The cache-control
won't apply to the image if you're setting it on the HTTP response for the
page as a whole, or if the image is just an <IMG SRC="myimage.png" />
tag that's been rendered. In this situation, the user agent makes two requests,
one to grab your page containing the <IMG> tag, and then a second request
for the .png file specified in that <IMG> tag. If you set cache-control on the
page to expire immediately, then that doesn't affect the request/response for
the .png file directly (because that response doesn't have a cache-control on
it). I'm only speculating about what your situation looks like here, it's really
two entirely different scenarios: (a) a WebForm producing a dynamic image
with Content-Type: image/png (or other graphics file format), vs. (b) a Web-
Form with a WebControl producing an <IMG SRC="myimage.png"/> tag
where the browser makes a second request that's separate to fetch the image.
One tool that you may try is the power toy, Fiddler, described in this article
and a free download from MSDN,
http://msdn.microsoft.com/ie/default...trofiddler.asp
Check that the browser is receiving the Cache-Control HTTP header on the
request for the image.
Another place to check potentially are the IIS logs which you can usually find in the,
C:\WINDOWS\SYSTEM32\LOGFILES\W3SVC1
directory on the web server. If the request coming in for the image was responded
to with an HTTP Status Code 304, then IIS told the browser that the image
requested hasn't changed (based on its timestamp) and the browser should get
it from its cache.
Derek Harmon