[REPOST] Dispable Http Caching

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Abhishek Srivastava (abhishek-srivastava_at_nospam.net)
Date: 02/10/04


Date: Tue, 10 Feb 2004 18:58:09 +0530

Hello All,

Apologies to everyone, I posted this before but received no response. I
feel someone must have come accross this problem before, and I need a
solution desparately.

I have written a C# program which downloads a file from a webserver on a
daily basis. (http://www.myserver.com/myfile.asp)

The problem is that either the proxy/browser's cache is being used
because my C# program runs successfully but downloads the file from
previous run.

Now, if I open my browser and visit that URL, click refresh plenty of
times, I see the latest file. Now if I run my C# program to download
file, the program also downloads the latest file.

So the either the Browsers or the proxy's cache is being used.

I want to always download the latest file. So my C# program should not
use the cache at all.

How do I make sure that no cache is used (either the browser or proxy).
Here is the code snipped from my program.

HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://www.myserver.com/downloadfile.asp");
WebProxy proxy = new WebProxy();
proxy.Address = new Uri("http://myproxy:8088");
request.Proxy = proxy;
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
if (response != null)
{
  Stream responseStream = response.GetResponseStream();
  Encoding encoding = Encoding.GetEncoding("UTF-8");
   if (reader != null)
   {
      char[] buffer = new char[BUFFER_SIZE];
      int count = reader.Read(buffer, 0, BUFFER_SIZE);
      while(count > 0)
      {
        ......
      }
   }
}

I saw all the properties of the HttpWebRequest and WebProxy classes but
could find anything which disables caching for me.

Thanks for your help in advace.

regards,
Abhishek.



Relevant Pages

  • Dispable http Caching at proxy and local level
    ... I have an application which downloads a file from the ... HttpWebRequest request = ... HttpWebResponse response = request.GetResponse; ... could find anything which disables caching for me. ...
    (microsoft.public.dotnet.languages.csharp)
  • [REVS] Introduction to HTTP Response Splitting
    ... single HTTP request that forces the web server to form an output stream, ... one response. ... HTTP response splitting is a fairly new web application vulnerability. ... Web cache poisoning: In this form a rather larger defacement takes place ...
    (Securiteam)
  • Re: How to clean up routing cache?
    ... I actually need criteria that shows that DNS response is slow. ... The local cashing of response disturbs the picture since the timeout ... value for the cache seems longer than i am going to do probing... ... > And even if your host did not cache the negative answer, ...
    (comp.unix.solaris)
  • Re: strlen(), K+1: clarification
    ... Note the 'is said to' tactic, diverting attention away from the fact ... and responsible C programmers generally avoid non-CT- ... And if you have to work with strings longer than cache length, ... Trying to cut off the easy response of 'memory is the bottleneck' by ...
    (comp.programming)
  • Re: 70-305 question still waiting...
    ... and franlky I do not care much where the cache ... > method, request header fields, and the response status indicate that it is ... > following Cache-Control response directives allow an origin server to ...
    (microsoft.public.cert.exam.mcsd)