1

I trying enable output compression for Apache 2.2.15, and 5.3.3, but web-pages generated by php is not compressing :(

My 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

And string in vhost config file for logging:

CustomLog logs/vhost/deflate_log deflate

And what I see in 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%)

What is wrong?

Giacomo1968
  • 3,522
  • 25
  • 38
Hayate
  • 161
  • 1
  • 8
  • check this answer: http://serverfault.com/questions/555140/apache-mod-deflate-does-not-compress-php-output/555260#555260 – regilero Nov 17 '13 at 11:58
  • Also this answer: http://stackoverflow.com/questions/5230202/apache-addoutputfilterbytype-is-deprecated-how-to-rewrite-using-mod-filter – Giacomo1968 Nov 17 '13 at 13:22

1 Answers1

0

This answer gives the best summary of issues that can pop up in Apache 2.2 with mod_deflate. The solution is to use filter_module & deflate_module instead:

# 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
Giacomo1968
  • 3,522
  • 25
  • 38