Who Add “_” Single Underscore Query Parameter?

后端 未结 5 1362
一个人的身影
一个人的身影 2020-12-01 08:47

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

10.1.1.211 - - [02/Sep/2010:16:14:31 -0400] \"GET /request?_=1283458471913&         


        
相关标签:
5条回答
  • 2020-12-01 09:25

    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
    
    0 讨论(0)
  • 2020-12-01 09:25

    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.

    0 讨论(0)
  • 2020-12-01 09:27

    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 : "");
    }
    
    0 讨论(0)
  • 2020-12-01 09:29

    It could be the JQuery CacheBuster parameter.


    Resources :

    • [jQuery] GData JSON queries "Invalid query parameters:_"
    • [jQuery] Turn off Cache Busting in $.getScript
    • Cache-busting
    0 讨论(0)
  • 2020-12-01 09:39

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

    0 讨论(0)
提交回复
热议问题