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.

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

  • 相关阅读:
    使用turtle库绘制一个叠加等边三角形
    使用turtle库绘制图形
    tar命令常用参数讲解
    elasticsearch 中geo point地理位置数据类型
    count(*)和count(1)的sql性能分析
    别再if/else走天下了
    正则表达式 匹配0次1次或者无限次
    linux shell 字符串操作(长度,查找,替换)
    linux expect工具使用
    mongodb分片balance
  • 原文地址:https://www.cnblogs.com/ytkah/p/13370125.html
Copyright © 2011-2022 走看看