Compressing content with PHP ob_start() vs Apache Deflate/Gzip? -
Most sites want to narrow their content to save on bandwidth, however, when Apache servers run on PHP, There are two ways - or with Apache, which is fast or easy on your server?
For example, in PHP I run the following function at the beginning of your pages to enable it:
/ ** * Gzip compressed page output * from the original function Came wordpress.org * / function gzip_compression () {// If any encoding was given - so it does accept gzip pages, (empty ($ _ server ['HTTP_ACCEPT_ENCODING'])) {Unreal Returning enabled needed; } // zlib If the page is not already compressed - and if ob_gzhandler is set, then ((ini_get ('on' 'zlib.output_compression' ') == or ini_get (' zlib.output_compression_level ')>) or Ini_get ('output_handler') == 'ob_gzhandler') {return false; } // If zlib is loaded otherwise, start compression. If (! Extension_loaded ('zlib') and (strpos ($ _ server ['HTTP_ACCEPT_ENCODING'], 'gzip') == FALSE) {ob_start ('ob_gzhandler'); }}
Use Apache (both of which) to enable them, you can add something to your .htaccess file like this.
AddOutputFilterByType Air Removal Text / html text / plain text / xml application / x-httpd-php
Since PHP is a scripting language (which is a PHP I'll assume that Apache method 1) will be more stable and 2) will be faster but assumptions in the real world are not high.
Finally, you will assume that the large financial backing window Together ... Uh , we will not go there.
We are running ... dealing with many webserver, 60m / unit / day generally But it is not worth mentioning, but your question seems to be based on experience.
We run with it in Apache. Whatever you choose, what happens outside of the other end (or it is not enough, it does not matter).
We select Apache for a few reasons:
- Zero maintenance, we have turned it on
- Maintain any case structure Is not required
- Demonstrations, in our test servers, where Apache had worked a little better at work.
- Apache will apply the output filter for all, PHP. On some occasions, the other types of content are being worked on the same server, we have our own .csss and .js
a word of warning, some browsers or other applications purposefully compressing Clients indicate the headings that compression is supported. Some people do this to reduce their job in client-side security (applications like Norton Internet Security and so on). You can either ignore it, or try to add additional cases to re-write requests to see common issues (Browser supports it, application or proxy to make it easier for your life Lighted).
Alternatively, if you are using the flush () command to send the output to the browser first, and you are implementing the compression, then with the white string to knock you down the server Pad may need data send quickly
Comments
Post a Comment