Posted on 2013-03-07 19:03:17 network
最近在折腾一个长连接HTTP服务器的时候,积累了一些经验,下面总结出来:
最好使用支持HTTP/1.1的服务器,HTTP/1.1默认支持keep-alive,不需要像HTTP/1.0那样检测Connection: keep-alive.
浏览器的刷新也会断开长连接,如果在服务端有一些判断,要注意发生重复的可能。
在用户关闭浏览器的标签的时候,如果有多个页面和服务器保持长连接,服务器应检测对应的页面,并做清理。
将长连接服务器位于反向代理之后,应在反向代理服务器上设置保持keep-alive,如nginx。 这样可显著减少后端upstream服务器的压力。
检测用户刷新页面,如果刷新应询问用户是否真的刷新。这样可以减少一些误判断。 如WEBQQ在检测到用户刷新时,对应的动作是重新登录。 这样做是很好,可以预防用户在当前页面重复触发一些业务逻辑。
如因为业务需要将长连接和会话绑定(很多WEB IM都这样做),应注意清理服务端保持的长连接。 发送完消息,就应该删除这个长连接。因为浏览器ajax请求还会立即请求的。
Never seen a betetr post! ICOCBW
brand prednisone online buy prednisone 5 mg online Canadian Pharmacy Viagra 100
paxil narcotic paxil 12.5 mg why does paxil make you gain weight stopped taking paxil when moving eyes a sound can be heard
nolvadex supplement nolvadex for sale uk nolvadex and clomid combined dosages when to take nolvadex morning or night
viagra for free buy cheap viagra online getting a prescription for viagra what is cialis used for
Weight gain Fatigue Dry, brittle nails Itching Constipation Irregular menstrual cycles Cold sensitivity cialis online increasing social interactions
great content custom soap packaging
The following should be considered while making this decision finax for sale
fantastic put up. I was checking continuously this weblog and i’m inspired! Very useful statistics specifically the last part i care for such information a lot. I was looking for this specific facts for a very long time. Thanks and first-rate of success. High-quality publish. someone write my assignment I used to be constantly checking this text and i am inspired! Extraordinarily beneficial statistics, in particular the principle part. I care for such info loads. I was looking for this particular information for a totally long term. Good good fortune and thank you
I imagine his paintings would score quite high on the The vcom icon.