mod_deflate – 大多数浏览器的最佳configuration

我想知道如果有人在这里可以帮助我确定使用mod deflate与Apache的最佳标准configuration。 基本上,mod_deflatebuild议使用以下configuration立即开始:

只压缩几个types

AddOutputFilterByType DEFLATE text / html text / plain text / xml http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

但是,只需阅读文档,就可以为所有浏览器自定义此文档。 另外,你可以为所有不同types的MIMEtypes定制mod_deflate。 我想知道有没有人试过这些设置,并find了一个最适合所有浏览器的设置。

Apache提供的另一个示例,但是如果您不了解所有configuration选项,请提及不要使用:

<Location /> # 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 </Location> 

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

我了解大部分的configuration设置,我想设置类似的东西。 我不介意避免已经压缩的图像和其他媒体的压缩。 我遇到的问题的细节是明白这是如何与所有不同的浏览器,铬,Firefox,IE浏览器,歌剧院等反应…显然,我不关心Netscape 4.X. 我希望有人已经testing了这一切,并可能能够推荐一个符合这个标准的好设置。

我的意思是,如果只是在文档中使用推荐的设置的问题,我很好,但我想检查只是为了确保。

只是提供一些额外的细节。 我们使用Apache作为我们所有Web服务的前端。 例如:confluence,git,gitweb等…

Tomcat和其他服务通过Apache代理,所以我们有虚拟主机的configuration,mod_proxy w / AJP,mod_ssl。

我的公司没有一个专门的IT团队,所以我必须在业余时间里设置大部分。 我将不胜感激任何input,你可以提供。

因此,为了清楚地说明我在问什么,处理基本内容的最佳configuration需要Apache向主stream浏览器提供服务请求?

我到目前为止的基本内容types列表:

  • text / html的
  • 纯文本/
  • 文/ XML
  • 文/ X-JS
  • 文/ JavaScript的
  • 文/ CSS
  • 应用程序/ XML
  • 应用/ XHTML + xml的
  • 应用程序/ x-JavaScript的
  • 应用程序/ JavaScript的
  • 应用程序/ JSON

显然不需要压缩的types:

  • 图像 – gif,jpg,png
  • 档案 – exe,gz,zip,坐,rar

我继续研究这一个。 在阅读了多个教程和Apache文档之后,我能够拼凑出一些实质性的东西,这似乎很好。 使用上面的列表,我把一组似乎可以处理主stream内容types压缩的规则/声明组合在一起:

 <Location /> # Insert filter SetOutputFilter DEFLATE AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/x-javascript application/javascript AddOutputFilterByType DEFLATE application/json BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \ \.(?:exe|t?gz|zip|bz2|sit|rar)$ \ no-gzip dont-vary SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary </Location> 

为了testing,我基本上使用了TamperData for Firefox,并打开了apache的deflate logging:

https://addons.mozilla.org/en-US/firefox/addon/tamper-data/

对于Apache,请添加以下内容:

 # For Testing Purposes DeflateFilterNote Input instream DeflateFilterNote Output outstream DeflateFilterNote Ratio ratio #LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate CustomLog logs/deflate_log deflate 

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#deflatefilternote