mod_deflate, centos, aplicativo / x-httpd-php

1

Estou tentando ativar a compactação de saída para o Apache 2.2.15 e 5.3.3, mas as páginas da web geradas pelo php não estão sendo compactadas: (

Meu deflate.conf:

[user@host conf.d]# cat deflate.conf 
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

DeflateCompressionLevel 9

# Browser specific settings
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bOpera !no-gzip 

# Setup custom deflate log
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
# Example of log file
CustomLog logs/deflate_log DEFLATE

E digite vhost arquivo de configuração para registro:

CustomLog logs/vhost/deflate_log deflate

E o que eu vejo no log:

"GET /tag/%D0%BF%D0%BB%D1%83%D1%82%D0%BE%D0%BD/ HTTP/1.1" -/- (-%)
"GET /2011/02/28/%D1%88%D0%BA%D1%83%D1%80%D0%BA%D0%B8-%D1%81-%D0%B7%D0%BE%D0%BD%D0%B0%D0%BC%D0%B8-%D0%BF%D1%80%D0%BE%D0%B1%D0%B8%D1%82%D0%B8%D1%8F/ HTTP/1.1" -/- (-%)
"POST /wp-login.php HTTP/1.1" -/- (-%)
"GET /2011/04/08/%D0%BA%D0%B0%D0%BA-%D0%B7%D0%B0%D1%80%D0%B0%D0%B1%D0%B0%D1%82%D1%8B%D0%B2%D0%B0%D1%82%D1%8C-%D0%B1%D0%BE%D0%BB%D1%8C%D1%88%D0%B5-%D0%BA%D1%80%D0%B5%D0%B4%D0%B8%D1%82%D0%BE%D0%B2-%D0%B2-world-of-tanks/ HTTP/1.1" -/- (-%)
"GET /wp-content/themes/the-erudite/css/erudite.css HTTP/1.1" 4368/15392 (28%)
"GET /wp-content/plugins/wp-table-reloaded/css/plugin.css?ver=1.9.4 HTTP/1.1" 396/980 (40%)
"GET /wp-content/plugins/wp-downloadmanager/download-css.css?ver=1.50 HTTP/1.1" 457/1980 (23%)
"GET /wp-content/uploads/2012/03/first-120x240-3.gif HTTP/1.1" -/- (-%)
"GET /wp-content/plugins/loginza/img/vkontakte.png HTTP/1.1" -/- (-%)
"GET /wp-includes/js/comment-reply.min.js?ver=3.7.1 HTTP/1.1" 387/753 (51%)
"GET /wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1 HTTP/1.1" 3050/7200 (42%)
"GET /wp-content/themes/the-erudite/js/common.js HTTP/1.1" 2570/6379 (40%)
"GET /wp-content/themes/the-erudite/js/jquery.scrollTo-min.js?ver=1.4.2 HTTP/1.1" 1181/2252 (52%)
"GET /wp-content/plugins/wp-recaptcha/recaptcha.css HTTP/1.1" 584/1739 (33%)
"GET /wp-includes/js/jquery/jquery.js?ver=1.10.2 HTTP/1.1" 32725/93085 (35%)

O que está errado?

    
por Hayate 17.11.2013 / 12:46

1 resposta

0

Esta resposta dá a melhor resumo de problemas que podem aparecer no Apache 2.2 com mod_deflate . A solução é usar filter_module & deflate_module em vez disso:

# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare  gzip CONTENT_SET

# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no

# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript

# Add "gzip" filter to the chain of filters
FilterChain    gzip
    
por 17.11.2013 / 14:22