Javascript 谁添加“_”单下划线查询参数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3687729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 05:42:48  来源:igfitidea点击:

Who Add "_" Single Underscore Query Parameter?

phpjavascriptajaxapachehttp

提问by ZZ Coder

I have a PHP server running on Apache, I get lots of request looks like this,

我有一个在 Apache 上运行的 PHP 服务器,我收到很多这样的请求,

10.1.1.211 - - [02/Sep/2010:16:14:31 -0400] "GET /request?_=1283458471913&action=get_list HTTP/1.1" 200 547 0 "http://www.example.com/request" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)" 28632 15602

The _ parameter is mysteriously added to the request. I am trying to find out who is doing that.

_ 参数神秘地添加到请求中。我试图找出谁在这样做。

There is a NetScaler running in front of Apache.

有一个 NetScaler 在 Apache 前面运行。

回答by Patricia

jQuery adds a parameter like that to get around IE's caching.

jQuery 添加了一个类似的参数来绕过 IE 的缓存。

edit: it only adds it for get requests, and only if the option cache is false:

edit: it only adds it for get requests, and only if the option cache is false:

cache: false

回答by Artefacto

Probably it's a dummy parameter added by the reverse proxy to force non-cached content to be served.

可能这是反向代理添加的虚拟参数,用于强制提供非缓存内容。

回答by jfrobishow

1283458471913 is a unix timestamp in ms, probably a bot/proxy making sure that they get a fresh page and not a cached version.

1283458471913 是一个以 ms 为单位的 unix 时间戳,可能是一个机器人/代理,确保他们获得一个新页面而不是缓存版本。

Could also be jQuery which would cause this for AJAX request of you have the nocache attribute set to true.

也可能是 jQuery,它会导致您将 nocache 属性设置为 true 的 AJAX 请求。

if ( s.cache === false && type == "GET" ) {
    var ts = now();
    // try replacing _= if it is there

    var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "_=" + ts + "″);
    // if nothing was replaced, add timestamp to the end

    s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
}