How can we handle compression in both? Whose responsibility is it? Which one is better, using apache or php to compress files?
PHP compression code:
ob_start("ob_gzhandler");
Or the apache one:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
Is this right that requests first reach in apache then to PHP? If answer is positive so can we infer that we should use the apache one?
Well here is what I know, presented in a pros and cons way.
Apache:
cache .htaccess files by default.
and the server will automatically pick them up
With PHP, you cannot write everything in once place. There are
many other things your .htaccess should have, besides compression:
A charset, expiry/cache control, most likely a few URL re-write
rules, permissions, robot(Googlebot etc) specific stuff.
As far as I know, you cannot do all of this solely with PHP, and since you may need to get all of this done, I don’t see why you should combine both of them.
I have always relied on .htaccess or server level configuration to control the above enumerated aspects, and rarely ever had a problem.
PHP:
problems.
default configuration which messes with your settings(and nerves).
Overall, Apache is the winner. That’s what I would go with all the time!