欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

apache 保持在.htaccess Alive功能 keep alive feature in .htaccess

保持在.htaccess Alive功能

我想使用保持活动的Apache功能我如何使用我的主机(htaccess的),什么应该是最好的值,如KeepAliveTimeout的参数

谢谢

--------------解决方案-------------

你无法控制在保留行为.htaccess 保活很多级别的功能,而不是一个不同的地方目录可以表现不同取决于每个目录htaccess的信息。

如果你是那种基本的共享主机,只有让你.htaccess配置您的网站,你不能改变保活设置。 想必托管公司将有适当地配置它们,或刚刚离开他们的默认设置,这通常是罚款。

如果keep-alive已开启Apache的配置,你需要的只是设置一个HTTP头连接:保持活动。 如增加以下行到你的.htaccess文件:

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

是保持活动状态的行为可以 .htaccess文件来控制。 首先通过打印检查服务器设置$_SERVER如果

[HTTP_CONNECTION] => keep-alive 

在那里,那么你只需要在您的.htaccess文件中的设置。 添加下面一行在项目的根目录下的.htaccess文件的末尾。

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

这在很大程度上取决于你的网站,它接收的通信量。 如果一个用户来到你的网站,然后通过给的KeepAliveTimeout设置(默认为15)中的另一个页面点击,一个新的TCP不必创建。 这可以真正帮助的开销。

在另一方面,当前捆绑瓦特/现有游客的任何Apache进程将无法去跟新的。 所以,你可能必须增加可Apache进程的总数。

总之...它需要调整。

你无法控制的.htaccess保持活动的行为

如果你有SSH访问你的服务器,你应该修改Apache的配置文件。 使用这些设置作为首发:

  • keepalive:指定的
  • 的KeepAliveTimeout:3秒
  • MaxKeepAliveRequests:60

这应该与平均行车最基本的服务器设置。 您可以随时调整设置,以满足自己的需要。 看到这里,以便了解更多详细信息:http://www.giftofspeed.com/enable-keep-alive/

如果您没有访问您的服务器,你应该联系您的主机。 通过编辑.htaccess文件可能不工作改变你自己存活的设置。

我想使用保持活动功能的Apache我如何使用我的主机(htaccess的),哪些应该是最佳值一样的KeepAliveTimeout参数

谢谢

 

5回答

你无法控制在保留行为.htaccess保活是一个主机级别的功能,而不是一个不同的地方目录可以表现不同取决于每个目录的htaccess的信息。

如果你是那种基本的共享主机,只有让你.htaccess来配置你的网站,你不能改变保活设置。想必托管公司将有适当地配置它们,或刚刚离开他们的默认设置,这通常是罚款。

 
 
感谢bobince,应该是什么的超时时间,因为我的网站没有流量感谢的大量 -  vipinsahu 2月4日在'10 15:19
 
如果你的主机没有改变它,在Apache 2.0中默认是15秒,而2.2是5秒。无论设置为完全合理的。-  bobince 2月4日在'10 15:23

如果keep-alive在Apache配置开启时,所有你需要的仅仅是设置一个HTTP头连接:保持活动。例如,添加以下行.htaccess文件:

<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>
 
2 
你的先生,更值得赞扬这一点。-  PaulSkinner 10月2日在'12 15:17
 
 
我就坚持“IfModule”而不是“ifModule”反正。-  爱马仕 5月16日16:41

这在很大程度上取决于你的网站和流量的接收量。如果一个用户来到你的网站,然后通过对设定的KeepAliveTimeout(默认为15)中的另一个页面点击,一个新的TCP不必创建。这可以用开销真正的帮助。

在另一方面,当前捆绑瓦特/现有访客的任何Apache进程将无法去跟新的。所以,你可能要增加可Apache进程的总数。

总之...它需要调整。

 
 
谢谢你的回答,但保活是不是在我的网站工作的我怎样才能让我的网站没有流量感谢了很多量 -  vipinsahu 在15:01 2月4日'10

你无法控制在.htaccess中保持活动行为

  

是保活的行为可以被控制的.htaccess文件。首先由印刷检查服务器设置$_SERVER,如果

[HTTP_CONNECTION] => keep-alive

在那里,那么你只需要在您设置的.htaccess文件。添加下面一行在年底的.htaccess在项目的根目录下的文件。

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

来自  http://www.55228885.com/mpYxv9zA.html

我想使用保持活动功能的Apache我如何使用我的主机(htaccess的),哪些应该是最佳值一样的KeepAliveTimeout参数

谢谢

 

5回答

你无法控制在保留行为.htaccess保活是一个主机级别的功能,而不是一个不同的地方目录可以表现不同取决于每个目录的htaccess的信息。

如果你是那种基本的共享主机,只有让你.htaccess来配置你的网站,你不能改变保活设置。想必托管公司将有适当地配置它们,或刚刚离开他们的默认设置,这通常是罚款。

 
 
感谢bobince,应该是什么的超时时间,因为我的网站没有流量感谢的大量 -  vipinsahu 2月4日在'10 15:19
 
如果你的主机没有改变它,在Apache 2.0中默认是15秒,而2.2是5秒。无论设置为完全合理的。-  bobince 2月4日在'10 15:23

如果keep-alive在Apache配置开启时,所有你需要的仅仅是设置一个HTTP头连接:保持活动。例如,添加以下行.htaccess文件:

<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>
 
2 
你的先生,更值得赞扬这一点。-  PaulSkinner 10月2日在'12 15:17
 
 
我就坚持“IfModule”而不是“ifModule”反正。-  爱马仕 5月16日16:41

这在很大程度上取决于你的网站和流量的接收量。如果一个用户来到你的网站,然后通过对设定的KeepAliveTimeout(默认为15)中的另一个页面点击,一个新的TCP不必创建。这可以用开销真正的帮助。

在另一方面,当前捆绑瓦特/现有访客的任何Apache进程将无法去跟新的。所以,你可能要增加可Apache进程的总数。

总之...它需要调整。

 
 
谢谢你的回答,但保活是不是在我的网站工作的我怎样才能让我的网站没有流量感谢了很多量 -  vipinsahu 在15:01 2月4日'10

你无法控制在.htaccess中保持活动行为

  

是保活的行为可以被控制的.htaccess文件。首先由印刷检查服务器设置$_SERVER,如果

[HTTP_CONNECTION] => keep-alive

在那里,那么你只需要在您设置的.htaccess文件。添加下面一行在年底的.htaccess在项目的根目录下的文件。

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




来自  http://wenda.mojijs.com/Home/question/detail/id/2200566/p/1/index.html




Optimize your website by tweaking .htaccess settings

I hope you know that slow web pages scare away visitors, while fast pages lead to higher visitor engagement, retention, and conversions.  Here are some suggestions to optimize your web site to get large performance wins with the least development effort. You can use Google PageSpeed to verify that your settings are working.

“The task is to extract the maximum amount of milk with the minimum of moo. And I am afraid to say that these days all I get is moo.”
 (Terry Pratchett, Jingo)

Enable “Keep-Alive”

HTTP keep-alive, also kwown as HTTP persistent connection, or HTTP connection reuse, means using a single connection to send multiple HTTP requests from the browser to the server.

If Keep-Alive is not enabled, the browser needs to open a new connection  for every single component of a web page, like images, style sheets and javascripts. That means the number of connections opened on the server can be ten fold compared to having Keep-Alive enabled.

Enable Compression

Compressing resources with gzip or deflate can reduce the number of bytes sent over the network. Text based resources like HTML, CSS and javascsript can easily be reduced in size by 30-50% by utilizing the automatic compression of web servers.

Enable Browser Caching

Your web site most likely contains many images and CSS/ javascript resources that doesn’t change very often. If your server isn’t correctly configured, every time a user loads a page the browser checks whether these resources have changed. Setting an expiry date or a maximum age in the HTTP headers for such resources tells the browser to user a previously downloaded local copy without even checking if the file has changed on the server.

Sometimes this can cause problems: you make changes to a CSS or javascript file, but the user browsing the site still sees the old version.

Complete optimized .htaccess file for your web site

Below is a .htaccess script that does all the optimazions mentioned above. First, it enables Keep-Alive. Secondly, it enables browser caching of images (for two weeks) and CSS/javascript/flash scripts (for two days). You can easily modify these time limits according to your needs. Finally, it enables compression of all requested files, exept images (gif, jpg, jpeg, png) as those are already compressed. It contains a workaround for Netscape 4.0 as it has some problems handling compressed files.

#Headers
<ifModule mod_headers.c>
 Header set Connection keep-alive
</ifModule>
<IfModule mod_expires.c>
 ExpiresActive On
 <FilesMatch "\.(ico|jpg|jpeg|png|gif)$">
  ExpiresDefault "access plus 2 weeks"
 </FilesMatch>
 <FilesMatch "\.(js|css|swf)$">
  ExpiresDefault "access plus 2 days"
 </FilesMatch>
</IfModule>
<IfModule mod_deflate.c>

# Insert filter
 SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
 BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
 BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
 BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
 SetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
 Header append Vary User-Agent env=!dont-vary
</IfModule>
 
 

普通分类: