Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 620
therobyouknow Avatar asked Jun 16 '10 16:06

therobyouknow


People also ask

How do I disable HTTP cache?

Here's how... When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

Are GET requests cached?

By enabling the caching of GET requests, you can improve the response times of requests for resource data that were previously submitted by the same user. When caching is enabled, the data is retrieved from the browser cache instead of from the business object on the server.

How do I stop page caching in HTML?

Select the HTTP Headers tab. Select the Add button in the Custom HTTP Headers group, and add Cache-Control for the header name and no-cache for the header value.

Which HTTP caching header is used to avoid making requests to the origin server?

Expiration is the caching mechanism by which a client can entirely avoid making requests to the origin server. When the origin server specifies an explicit expiration time in the resource, a cache can check that expiration time and respond accordingly without having to contact the server first.


1 Answers

If you have control over the application targeted by the XMLHTTP Request (which is true in your case), you could let it send no-cache headers in the Response. This solved the issue in my case.

Response.AppendHeader("pragma", "no-cache");
Response.AppendHeader("Cache-Control", "no-cache, no-store");

As alternative, you could also append a querystring containing a random number to each requested url.

like image 56
krizzzn Avatar answered Sep 22 '22 10:09

krizzzn