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

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

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.

  • Thanks Silviud, but why use ZLIB when one can just add the php extension into the DEFLATE paragraph? Is ZLIB faster than DEFLATE for php files? if so, how to define other php content extensions to work with ZLIB? for example if a js or css file containing php code should also be ZLIBBED – Sam Dec 15 '10 at 18:59
  • if you don't know why is there is no real need to use it ... php has his own way where you can achieve the same thing but native. it can be used if you server large files for example (50MB) which you want to send compressed - you can play with buffered or non buffered output trough this as well. see the docs from php. – silviud Dec 15 '10 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.