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

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

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

神秘地将 _ 参数添加到请求中。

在 Apache 之前有一个 NetScaler。

31543 次浏览

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

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

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

cache: false

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

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

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


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


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

Ajax tools, like jQuery, is able to ask the browser not to cache the requested result, so every request from the loaded web page will travel to web server and get the newest response.

In order to achieve that, set cache flag as false, then an additional query parameter, like _=1234567890, is appended into the request URL. Of course the number is always changing, so the browser thinks it as a brand-new request and won't provide any cached things.