: Zlib compression issues I'm having some issues running zlib compression on my site .. Firstly if I enable zlib compression in .htaccess using: php_value output_handler ob_gzhandler then I receive
I'm having some issues running zlib compression on my site ..
Firstly if I enable zlib compression in .htaccess using: php_value output_handler ob_gzhandler then I receive thousands of lines of the following error:
PHP Warning: Cannot modify header information - headers already sent
in Unknown on line 0
I have checked all files used for whitespace and any other characters that shouldn't be there with a hex editor but I could not get that error to subside with zlib turned on in .htaccess.
Therefore I have tried to turn zlib compression on in the php.ini file using:
zlib.output_compression "1"
zlib.output_compression_level "1"
However I'm now told by compression checkers that I have no compression turned on so it doesn't appear to be in the correct format?
More posts by @Phylliss660
1 Comments
Sorted by latest first Latest Oldest Best
The first thing to keep in mind is that compression checkers sometimes lie for various reasons, so take their warnings with a grian of salt. As a few people have recently said on Stack Overflow ySlow is not gospel (but I do like it myself).
What I would suggest doing, rather than employing zlib.output_compression in php, is to enable mod_deflate in Apache. This will catch and compress static files as well (say, if you have static text files/csv/xml to serve). Keep in mind that you don't want to compress most multimedia like images and videos, since the overhead involved is proportionally inefficient when compared to the reduction in file size (which is virtually zero).
Here's an example relevant for httpd2, but there are a lot more options to choose from (check the manual):
<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
# 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>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.