“Connection: Keep-Alive” in server response

蹲街弑〆低调 提交于 2019-12-02 20:54:58

The Keep-Alive functionality is not meant for persistent connections.

Keep-Alive is meant to reduce the number of connections for a website. Instead of creating a new connection for each image/css/javascript in a webpage many requests will be made re-using the same connection.

There are some settings that prevent this in Apache too, like maximum number of requests on a connection or timeouts between requests. This will also eat your resources very fast because every connection needs its own thread.

You should switch to another solution, that is made for that kind of work.

For services that keep your connection open you can take a look at http://orbited.org and http://twistedmatrix.com/trac/

Since PHP doesn't manage the HTTP connection, it has no way to change this setting. You need to set that in servers. For example, you can enable keep-alive like this in Apache if you are using mod_php,

KeepAlive On
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!