Re: WebControl/Cache-Control question

From: Derek Harmon (loresayer_at_msn.com)
Date: 03/13/05


Date: Sat, 12 Mar 2005 23:59:24 -0500


"Nadav" <Nadav@discussions.microsoft.com> wrote in message news:9E58EB10-9D8A-493B-8E64-B7D5914AA1E7@microsoft.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.aspx?pull=/library/en-us/dnwebgen/html/ie_introfiddler.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



Relevant Pages

  • Re: How to write something to a html textfield and send it?
    ... > No need for controlling any particular browser. ... I'm not familiar with HTTP user ... and building the request in your program. ... The server doesn't know anything about a textfield; ...
    (comp.programming)
  • Re: Generated javascript from .pl files
    ... Because web servers might use a different HTTP specification than ... the visiting browser, so possible HTTP version conflicts arise. ... I'd like to see an otherwise usable Web client that does not support ... one that is used here does not rely on the (Content-* request) HTTP headers. ...
    (comp.lang.javascript)
  • Re: Http 401 Unauthorised
    ... Iain Adams wrote: ... A SoapException occurred: Message: The request failed with HTTP status ... If this is the first 401 this site has sent while the browser has been running, it will pop up the userid/password box on your screen. ...
    (comp.lang.php)
  • Re: making an http server
    ... > create a socket, bind it to a port number and start listening to the ... transmit it to the browser as a fake HTML response ... > web- this function returns the request back to the browser ... > read from the socket the HTTP request ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to write something to a html textfield and send it?
    ... No need for controlling any particular browser. ... I'm not familiar with HTTP user ... >> used easily to detect the html tags and the required textfield. ... or do you just need to submit the request with the appropriate ...
    (comp.programming)