VBScript:禁用从服务器到 HTTP GET URL 请求的响应缓存 [英] VBScript: Disable caching of response from server to HTTP GET URL request

查看:29
本文介绍了VBScript:禁用从服务器到 HTTP GET URL 请求的响应缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想关闭当从 Windows 机器上的应用程序中运行的 VBScript 对服务器进行 URL 调用时使用的缓存.我使用什么函数/方法/对象来执行此操作?

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?

当第一次调用时,我的基于 Linux 的 Apache 服务器从它正在运行的 CGI Perl 脚本返回响应.但是,脚本的后续运行似乎使用与第一次相同的响应,因此数据被缓存在某处.我的服务器日志确认在随后的时间里没有调用服务器,只有在第一次.

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

上述对象上是否有关闭缓存的函数/方法,或者我应该在创建 URL 之前调用方法/函数来关闭响应对象上的缓存?

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?

我在这里寻找解决方案:http://msdn.microsoft.com/en-us/library/ms535874(VS.85).aspx - 不够有帮助.在这里:http://www.w3.org/TR/XMLHttpRequest/ - 非常不友好并且难以阅读.

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.

我还试图通过 http 标头设置和 html 文档标头元数据强制不使用缓存:

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

将响应返回给调用客户端的服务器端 Perl CGI 脚本片段,将到期时间设置为 0.

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 头设置:

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>

上面的 http 头和 html 文档头设置不起作用,因此我的问题.

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

推荐答案

我认为 XMLHTTP 对象本身甚至没有实现缓存.

I don't think that the XMLHTTP object itself does even implement caching.

您在调用 .send() 后立即发送一个新请求.缓存的全部意义在于避免发送请求,但这不会发生在这里(就您的代码示例而言).

You send a fresh request as soon as you call .send() on it. The whole point of caching is to avoid sending requests, but that does not happen here (as far as your code sample goes).

但是如果该对象在某种浏览器中使用,那么浏览器可能会实现缓存.在这种情况下,常见的方法是在语句中包含一个缓存破坏器:每次发出新请求时都会更改的随机 URL 参数(例如,将当前时间附加到 URL).

But if the object is used in a browser of some sort, then the browser may implement caching. In this case the common approach is to include a cache-breaker into the statement: a random URL parameter you change every time you make a new request (like, appending the current time to the URL).

或者,您可以让您的服务器发送一个 Cache-Control: no-cache, no-store HTTP 标头,看看是否有帮助.

Alternatively, you can make your server send a Cache-Control: no-cache, no-store HTTP-header and see if that helps.

<meta http-equiv="CACHE-CONTROL" content="NO-CACHE> 可能没用,你可以完全放弃它.

The <meta http-equiv="CACHE-CONTROL" content="NO-CACHE> is probably useless and you can drop it entirely.

这篇关于VBScript:禁用从服务器到 HTTP GET URL 请求的响应缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆