Zlib Compression and Deflate compression. how to use correctly in htaccess

.htaccessapache-2.2compression

in order to speed up my website and php pages, i use compression my php pages currently fetch text, create thumbnails etc. Currently these two compression paragraphs are at the very bottom of my htaccess file. Should the both be there? Is this code correct?

What value is best for the zlib to go in my htaccess? I guese 16386 is default and equals to 16k or 16K . What if one puts there 2M ? Will that make php processing or page loading any faster? are there any other options one might add there except the number 16386? Any and all advices are welcome and honoured +1!

# preserve bandwidth for PHP enabled servers
<ifmodule mod_php4.c>
    php_value zlib.output_compression 16386
</ifmodule>

# compress speficic filetypes
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|eot|ttf|fon|svg|xml|ast|php)$">
    SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Best Answer

the zlib.output_compression level is from 0 to 9 according to the php docs

http://uk2.php.net/manual/en/zlib.configuration.phplink text

the setting zlib.output_compression will take any of these values - boolean "On|Off" or an integer that will be the output buffer size.

that will make your php to be processed a bit slower as it has to actually do the compression.

The mod_deflate it's quite standard from whatis written - you compresses all files that have any of those extensions at the Apache level - .php is included so unless there is a different requirement from your app to do compression at php level is not really need it to do it twice.