WebClient.DownloadData without cache

  • Thread starter Thread starter YA
  • Start date Start date
Y

YA

I am using WebClient to download a text file from the net every 2 minutes.
The problem is that I think I am reading the file from cache since when the
file is change I still get the old file.
Here is my code:
Dim myWebClient As New WebClient()
Dim responseArray As Byte() = myWebClient.DownloadData(szURL)

How can I tell WebClient not to use cache ?

Thanks in advance
(e-mail address removed)
 
Two things to try:

1) Server cache control:
..asp page instead of .txt file in your url, .asp includes anti-caching headers ahead of the text file content read from the text
file. see FileSystemObject in ASP to read the file content.

2) make browser think it's a new url:
append "?r=" & rnd * 999999 to the url of the txt file. The web server won't care about the trailing stuff but the browser thinks
it's gonna get a new result and will fetch it. This syntax may not be perfect but you get the idea that a constantly changing
QueryString portion of the URL will make browser keep pulling from the server.

Chris Langsenkamp
http://chat.cleverchat.net/

----- Original Message -----
I am using WebClient to download a text file from the net every 2 minutes.
The problem is that I think I am reading the file from cache since when the
file is change I still get the old file.
Here is my code:
Dim myWebClient As New WebClient()
Dim responseArray As Byte() = myWebClient.DownloadData(szURL)

How can I tell WebClient not to use cache ?

Thanks in advance
(e-mail address removed)
 
Back
Top