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

查看:124
本文介绍了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).

但是 if 在某种浏览器中使用对象,然后浏览器可以实现缓存。在这种情况下,常见的方法是在语句中包含一个缓存破坏者:每次发出新请求时都会更改的随机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:无缓存,无存储 HTTP标头,看看是否有帮助。

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

<元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天全站免登陆