“Connection: Keep-Alive” in server response

后端 未结 2 1453
别跟我提以往
别跟我提以往 2021-02-02 00:25

I\'m trying to establish a HTTP persistent connection from a Silverlight application to a PHP page (ie without creating a new TCP connection for each HTTP request) hosted by an

相关标签:
2条回答
  • 2021-02-02 01:16

    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
    
    0 讨论(0)
  • 2021-02-02 01:28

    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/

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