zoukankan      html  css  js  c++  java
  • Apache如何设置Enable Keep-Alive

      在优化网站性能的时候,我们会发现有些站点的Enable Keep-Alive分数很低,如何调整设置呢?HTTP持久连接(英语:HTTP persistent connection,也称作HTTP keep-alive或HTTP connection reuse)是使用同一个TCP连接来发送和接收多个HTTP请求/应答,而不是为每一个新的请求/应答打开新的连接的方法。如何设置Keep-Alive呢?随ytkah一起来看看,以Apache为例

      1、如果您无权访问Web服务器配置文件,则可以通过在.htaccess文件添加以下代码行来实现添加HTTP标头:

    <ifModule mod_headers.c> Header set Connection keep-alive </ifModule>
    

      2、如果您能够访问您的Apache配置文件,则可以通过在/ etc / httpd / conf /中找到的httpd.conf文件中的这3行更改来打开保持活动状态。

    KeepAlive On
    MaxKeepAliveRequests 0
    KeepAliveTimeout 100
    

      当然您可以调整具体的参数,可参考https://www.giftofspeed.com/enable-keep-alive/

    – KeepAlive: Set it to "KeepAlive on" to enable keep-alive. To disable it use "KeepAlive off".
    – MaxKeepAliveRequests: Sets the maximum number of requests for every keep-alive connection. A good number to start with is 60 requests per connection.
    – KeepAliveTimeout: Sets how long your server should wait for new requests from clients. The 15 second default is too high. Set it to 3 seconds to start with and gradually go up when it underperforms. Setting it to a lower amount of seconds results in less parallel connections which again results in less server load.

      做性能优化的朋友可以试试

  • 相关阅读:
    python3 sorted()函数解析
    MySql 关键字
    python的 a,b=b,a+b 和 a=b b=a+b 的区别
    python3 all() 函数用于检查实参
    Python3 urllib模块
    Python3 shutil模块
    Python3 sys模块
    Python 异常处理和断言
    Python3 os模块
    Pytho3 file open方法
  • 原文地址:https://www.cnblogs.com/ytkah/p/13370125.html
Copyright © 2011-2022 走看看