Chat application AJAX polling

前端 未结 12 1625
天命终不由人
天命终不由人 2020-12-14 20:11

In the project I am currently working on, we have the need to develop a web chat application, not a very complex chat, just a way to connect two people to talk about a very

12条回答
  •  悲&欢浪女
    2020-12-14 21:02

    The trick is to realise that the only time your app needs to invoke CGI on the server is when someone says something. For the regular polls, poll a static page that your CGI script updates whenever there is new chat. Use HEAD requests, compare the timestamps with those last seen, and only do a full GET when those change. I have a simple naive chat application implemented this way, and the load and bandwidth usage is negligible for the few tens of simultaneous users we have.

提交回复
热议问题