我看了其他答案,这些解决scheme没有帮助。
我完全困惑如何做到这一点。 我对apache几乎一无所知,也不知道如何使用它,几乎所有的文章都写这个,但没有告诉我在哪里。
到目前为止,我已经做到了
# a2enmod deflate Module deflate already enabled
然后我试图写在httpd.conf
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
然后我写了一个涉及deflate.c的较长版本。 之后那些没有工作,我删除了他们所有,并写了AddOutputFilterByType行在Apache2 / sites-enabled / 000默认内
我用这个来testinghttp://www.whatsmyip.org/http_compression/
每次它说没有压缩。 我用另一个网站,但我永远不能压缩。 另外,我重新启动服务器,每次我保存一个文件,那么可能是什么问题,我该如何正确启用?
尝试在所有目录configuration后将以下内容添加到您的Apache Siteconfiguration中。
它有一些规则来处理浏览器与GZIP压缩网页的斗争。
<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>