VBScript: Disable caching of response from server to HTTP GET URL request

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-06-16T16:57:08Z Indexed on 2010/06/16 17:12 UTC
Read the original article Hit count: 300

I want to turn off the cache used when a URL call to a server is made from VBScript running within an application on a Windows machine. What function/method/object do I use to do this?

When the call is made for the first time, my Linux based Apache server returns a response back from the CGI Perl script that it is running. However, subsequent runs of the script seem to be using the same response as for the first time, so the data is being cached somewhere. My server logs confirm that the server is not being called in those subsequent times, only in the first time.

This is what I am doing. I am using the following code from within a commercial application (don't wish to mention this application, probably not relevant to my problem):


With CreateObject("MSXML2.XMLHTTP")
  .open "GET", "http://myserver/cgi-bin/nsr/nsr.cgi?aparam=1", False
  .send
  nsrresponse =.responseText
End With

Is there a function/method on the above object to turn off caching, or should I be calling a method/function to turn off the caching on a response object before making the URL?

I looked here for a solution: http://msdn.microsoft.com/en-us/library/ms535874(VS.85).aspx - not quite helpful enough. And here: http://www.w3.org/TR/XMLHttpRequest/ - very unfriendly and hard to read.

I am also trying to force not using the cache using http header settings and html document header meta data:

Snippet of server-side Perl CGI script that returns the response back to the calling client, set expiry to 0.


    print $httpGetCGIRequest->header(
        -type    => 'text/html',
        -expires => '+0s',
        );

Http header settings in response sent back to client:


<html><head><meta http-equiv="CACHE-CONTROL" content="NO-CACHE"></head>
<body>
response message generated from server
</body>
</html>

The above http header and html document head settings haven't worked, hence my question.

© Stack Overflow or respective owner

Related posts about caching

Related posts about cache