在tomcat 7中启用mod_deflate?

时间:2014-07-19 19:15:08

标签: java tomcat amazon-web-services

我试图关注this tutorial在Tomcat 7上启用mod_deflate。

它提供了一个名为enable_mod_deflate.conf的文件,它希望将其复制到/etc/http.d/enable_mod_deflate.conf。我已经这样做了,但是当我重新启动Tomcat时,我没有在我的javascript文件上看到gzip标头。

这些是我的enable_mod_deflate.conf文件的内容:

<IfModule mod_deflate.c>
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xml+rss
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/jpeg

# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9

# 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 \bMSI[E] !no-gzip !gzip-only-text/html

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

</IfModule> 

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

是的,你遗失了一些东西。

Tomcat和Apache是​​两个独立的服务。 Apache经常配置为将请求代理到tomcat。但是如果你对apache配置进行了更改,则需要重新启动apache。