Saturday, May 27, 2006

Microsoft.XMLHTTP and cached data

Once I had a problem with Microsoft.XMLHTTP object. It used cached results from previous fetch.
I solved the problem by appending a unique parameter to the URL, which caused the object to fetch the new result each time.
Something like this:
strUrl="http://server.com/servlet/GetData?docid=25C6&unique="+cstr(timer())


----------------------------

Sub Initialize
Dim oHTTP As Variant
Dim strUrl As String
Dim strReturn As String

strUrl = "http://server.com/servlet/GetData?docid=25C6&unique="+cstr(timer())

Set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "GET", strUrl, False, "", ""
oHTTP.send("")
strReturn = oHTTP.responseText
Set oHTTP = Nothing
msgbox strReturn
End Sub

4 comments:

dmanbrock said...

Brilliant. Just the fix I've been looking for!

dave gellert said...
This comment has been removed by the author.
dave gellert said...

thanks man you saved my bacon

Sbobet said...

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
Poker77
Judi Poker Online
Kiu Kiu Poker
Poker Texas Boyaa
Club poker88
domino338
Agen Sbobet