I've got the mod_deflate up and running. I can throw in a something.txt file in my apache server and use curl to check it out.
curl --compressed -I /somefile.txt gives me back the following which is good and compressed:
Vary: Accept-Encoding
Content-Encoding: gzip
But if i use /some.php i get back:
Accept-Ranges: bytes
X-Powered-By: PHP/5.4.4-14+deb7u5
But no Content-Encoding: gzip, the .htaccess i used with multiple options:
SetOutPutFilter DEFLATE
Or
AddOutputFilterByType DEFLATE application/json
I also checked if the zlib compression was turned off in the php.ini and also tried to set the output buffer to off. But no matter what i try i never get the php output to be compresse by apache. The overhead from apache to zip it is less than when i use php zlib.
I see enough posts like Apache output compression working for CSS/JS but not PHP but that enables compression from php. I want apache to handle it.
I must be missing something silly here.
UPDATE: I resolved all issues, also because of the answers given. In the end it still didn't work 100%. This was due to the wrong package installed. apache2filter was used which send me on the wrong path.
AddOutputFilterByType
is a deprecated way of adding things on the output filter chain (ref here ).:And you may have some problems because PHP is associated with one filter chain which does not contain the DEFLATE filter.
You could try to use the new syntax of mod_filter with FilterChain as shown in this question (in the question, not in the answers).
I had this problem and ended up discovering that setting the mod_deflate options in .htaccess vs. httpd.conf led to different results. The httpd.conf settings worked for PHP when run in fastcgi or as a DSO. In the .htaccess file, PHP running as fastcgi couldn't grok the deflate directives.
So try to write the rules in your httpd.conf instead of .htaccess and see if that solves your problem (don't forget to restart your Apache after making the changes).
Try this and see if it works for you: