Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript MSXML2.XMLHTTP.responsetext not updating when called again

I'm trying to develop a script that authenticates itself with a server then loops through getting new data from the server.

Bellow is a the code I'm using

Set s = CreateObject("MSXML2.XMLHTTP")

'Server authentication
s.open "GET", "fooAPI", False
s.send

do

    'Server data
    s.open "GET", "barAPI", False
    s.send
    Wscript.echo s.responseText
    WScript.Sleep 5000
loop

The first time it runs I get correct up to date info but once it loops it gives me the same info from the first run

The closest I could find was this But it was left unanswered.

I was planning on doing this all in python but I was denied my request as it was a "Security risk" to have python installed.

Any advise would be appreciated

like image 404
50-3 Avatar asked Feb 06 '26 17:02

50-3


1 Answers

It's because the response is being cached. Either change the settings of IE so it fetches a fresh copy each time, or send some random parameter that is not used to trick IE into thinking it's a different "page". If you control the server, you can set the HTTP headers to force the client (if it conforms to standards) it always fetch the content. See more info here as well: VBScript: Disable caching of response from server to HTTP GET URL request

(I know most of this information is Sandeep's link. However, having it here is nicer and that might disappear.)

like image 171
d-_-b Avatar answered Feb 09 '26 11:02

d-_-b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!