Webrequest Caching issue?

S

Saul

Hi all.

Well, we are in beta phase of testing and have uncovered a problem with the
"code Liveupdate" code I wrote as part of our nightly data sync. Here's how
it works in simple terms - The office web server has a text document on it
with nothing more than the version text in it, eg "1.0 Beta 19". The
handheld sync code gets this page, compares it with what it knows is it's
version number, and if they are different downloads and installs the updated
cab file. Works every time for me, and most users. But not all.

Here is what seems to be happening. Looking at the version page in Pocket IE
on an affected machine, I can see that it's caching the page. For example,
it returns "1.0 Beta 16" as the version page. When I refresh the page, it
goes to the server and updates it with the latest version, eg "1.0 Beta 19".
The problem with this caching is that the code always thinks it's the latest
version! It never goes back to the web server to check..Doh! My liveupdate
falls over and all hell breaks loose. This bit has to work in the production
version as it's the key to fixing any other problem and providing code
updates to our 300+ users without hardware recall. Gulp.

So, here is the code that gets the web version document, with a few
irrelevant lines deleted...

Dim Response As WebResponse
Dim ResponseStream As Stream
Dim Request As WebRequest
Dim strOnlineVersion As String = ""
Dim sReader As StreamReader

Try
Request = WebRequest.Create(strVersionURL) ' strVersionURL
set elsewhere, eg "http://server/version.txt"
Request.Timeout = 60000 ' 60 seconds I believe, should take no
more than 5 or 6
Response = Request.GetResponse
ResponseStream = Response.GetResponseStream
sReader = New StreamReader(ResponseStream)
strOnlineVersion = sReader.ReadLine
If constVERSION = strOnlineVersion Then
' No Update online
Else
' Update available!
' Download and install it. Yadda yadda.
<etc>

I am wondering why this is a per-machine problem. I am thinking it might be
a setting the the OS connections rather than a code related problem. Like I
said, the code above seems to work fine on my test handheld. Is there a way
to force the handheld to not cache? The users are syncing via activesync
passthough internet connections on an internet capable home PC. I have had
the thought that it may be a PC setting but I have seen a unit fail on my
dev PC, which otherwise works fine. So... I'm confused.

I could switch from a HTML based version checking mechanism to a SQL table
based one, but I'd rather not - it would mean re-coding some of the more
complicated parts of the sync code.

Thanks a great deal for any pointers or help in this, and feel free to ask
any questions. In a nutshell -- Does anyone know how to turn off caching for
the above webrequest?

Thanks,
Saul
 
A

Alex Feinman [MVP]

If you are using IIS, you should be able to set the file or the whole vdir
content to expire immediately - file or vdir properties/HTTP Headers/Enable
content Expiration
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top