How long will the browser wait after an ajax request?

前端 未结 4 1389
醉话见心
醉话见心 2020-12-07 22:41

How long can the browser wait before an error is shown before server answers for request? Can this time be unlimited?

4条回答
  •  自闭症患者
    2020-12-07 22:59

    I found, that in case of a normal (HTML page) request, browsers run to timeout after cca. 30 secs. It's important, because other participiants probably follows it: proxies, routers (do routers play in this game? I'm not sure). I am using 4 sec long server-side delay (if there's nothing to send to the client), and my AJAX client performs another HTTP request immediatelly (I am on local network, there's no internet lag). 4 sec is long enough to not to overload the server and network with frequented polls, and is short enough for the case, when somehow one poll falls out of the row which the client can't detect and handle.

    Also, there're other issues with comet (long HTTP request): browser's limit on number of simultaneous HTTP request, handling of client-side events (must sent to the server immediatelly), server/network down detection and recovery, multi user handling etc.

提交回复
热议问题