Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Sep 6 Previous

Item 547174

In order to use reduce bandwidth you want to turn on output compression. Wat do you do?

A. Set gzip.output_compression = on in the php.ini file.

B. Set zlib.output_compression = on in the php.ini file.

C. Set AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php in the Apache config file.

D. Nothing: when the browser connects with the server the server will automatically select the appropriate compression scheme based on the values set in the Accept-Encoding request header.

Answer

The correct answer is C, but it is not likely that this answer will be an option on the exam because it's an Apache web server setting. Making your web server responsible for dealing with output compression has numerous advantages (speed, maintenance, caching, static files) over just doing this for content generated by PHP scripts.

When you want to set compression on for all dynamic content generated by PHP then the answer is B. Answer A is just an answer to confuse you: there is no such setting in PHP.

Answer D is tricky: a browser can send an Accept-Encoding header along with its request (and most do). If it doesn't it will not expect to receive compressed data. If it does it merely hints the web server that it is OK to send compressed data, but the server itself still decides if it will comply to that request. In situation where bandwidth is abundant and/or the server has limited processing power a server administrator might very well decide that she/he doesn't want to use output compression and then a client will not be able to enforce this.