douqiang7462 2014-10-02 15:35
浏览 66

如何激活keep-alive,http://www.webpagetest.org表示keep-alive未激活

I have used http://www.webpagetest.org tool to check a web page, this indicates that keep-alive is not activated. I researched this and was led to How can I enable keep-alive? and Changing PHP $_SERVER['HTTP_CONNECTION'] value

Following from this I tried <ifModule mod_headers.c> Header set Connection keep-alive </ifModule> in the .htaccess file. The http://www.webpagetest.org tool still indicated keep-alive is not activated.

I contacted the hosting company and they stated that Keep-Alive is enabled.

I made a bare bones html test file (call this test.html) that sought to load two images, one from the server that did not keep-alive (call this notalive) and the other from a server (call this alive) that the http://www.webpagetest.org tool indicated is keeping alive.

Results:

when checking test.html hosted on server notalive with the webpagetest tool the image on server notalive indicates that keep-alive is not activated, however for the image on server alive the tool indicates that it is keep-alive.

I then swopped the test.html over to server alive and the webpage tool indicated exactly as per the test above that is for the image on notalive server the tool says keep-alive is not activated and for the the image on server alive the tool says keep-alive is activated.

This led me to believe that since the html files are identical that my issue might be due to configuration of the server notalive.

I ran phpinfo() from both servers and retained lines that seemed to do with alive (based on the above stackoverflow postings) and have reproduced those lines below.

For the notalive server:

PHP  Version  5.3.29

Configuration:  apache2handler:  Max  Requests  Per  Child:  500  -  Keep  Alive:  on  -  Max  Per  Connection:  100
Configuration:  apache2handler:Timeouts  Connection:  300  -  Keep-Alive:  1

Apache  Environment:  HTTP_CONNECTION  close

HTTP  Headers  Information:  HTTP  Request  Headers:  connection  close

Connection  keep-alive


PHP  Variables:  _SERVER["HTTP_CONNECTION"]  close

For the alive server:

PHP  Version  5.2.12

apache:  Max  Requests  Per  Child:  1000  -  Keep  Alive:  on  -  Max  Per Connection:  500
Timeouts  Connection:  300  -  Keep-Alive:  5


Apache  Environment:  HTTP_CONNECTION  keep-alive


HTTP  Headers  Information:  HTTP  Request  Headers:  Connection  keep-alive

HTTP  Headers  Information:  HTTP  Response  Headers:
  Keep-Alive  timeout=5,  max=500
  Connection  Keep-Alive

PHP  Variables:  _SERVER["HTTP_CONNECTION"]  keep-alive

I would be most obliged if someone would look at the above and perhaps offer some guidance on how to activate keep-alive.

Thank you for taking the time to read this.

  • 写回答

1条回答 默认 最新

  • duankousong9637 2014-10-03 10:22
    关注

    Sorted or at least a workaround.

    Based on my test results the hosting company have concluded that the issue is due to their use of Apache web server and Varnish Cache.

    They have moved the site over to Litespeed Server and the connections are now kept alive.

    Thanks Blowski for the assistance.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?