Note that there are some explanatory texts on larger screens.

plurals
  1. POCompressing content with PHP ob_start() vs Apache Deflate/Gzip?
    primarykey
    data
    text
    <p>Most sites want to compress their content to save on bandwidth. However, When it comes to apache servers running PHP there are two ways to do it - <a href="http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php" rel="nofollow noreferrer">with PHP</a> or with apache. So which one is faster or easier on your server? </p> <p>For example, in PHP I run the following function at the start of my pages to enable it:</p> <pre><code>/** * Gzip compress page output * Original function came from wordpress.org */ function gzip_compression() { //If no encoding was given - then it must not be able to accept gzip pages if( empty($_SERVER['HTTP_ACCEPT_ENCODING']) ) { return false; } //If zlib is not ALREADY compressing the page - and ob_gzhandler is set if (( ini_get('zlib.output_compression') == 'On' OR ini_get('zlib.output_compression_level') &gt; 0 ) OR ini_get('output_handler') == 'ob_gzhandler' ) { return false; } //Else if zlib is loaded start the compression. if ( extension_loaded( 'zlib' ) AND (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) ) { ob_start('ob_gzhandler'); } } </code></pre> <p>The <a href="https://stackoverflow.com/questions/388595/why-use-deflate-instead-of-gzip-for-text-files-served-by-apache">other option</a> is to use Apache <a href="https://stackoverflow.com/questions/1574168/gzip-vs-deflate-zlib-revisited">deflate or gzip</a> (both which are <a href="https://stackoverflow.com/questions/883841/why-do-real-world-servers-prefer-gzip-over-deflate-encoding/1579506#1579506">very close</a>). To enable them you can add something like this to your .htaccess file.</p> <pre><code>AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php </code></pre> <p>Since PHP is a scripting language (which must be loaded by PHP) I would assume that the apache method would be 1) more stable and 2) faster. But assumptions don't have much use in the real world. </p> <p>After all, you would assume that with the huge financial backing windows has... <em>uh</em>, we won't go there.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload