title: PHP - Sending gzip compressed JS/CSS
body: <p>I created a style.css.php file with this code:</p>
  
  <pre><code>&lt;?php
  
    $gzip = (ob_get_length() === false &amp;&amp; !ini_get("zlib.output_compression") &amp;&amp; ini_get("output_handler") != "ob_gzhandler" &amp;&amp; extension_loaded("zlib") &amp;&amp; substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') &amp;&amp; !headers_sent());
  
    if(!$gzip) header('Location: style.css');
  
    header('Content-type: text/css');
    header('Cache-Control: no-cache');
    header('Expires: Mon, 1 Jan 1901 04:20:00 GMT');
  
    ob_start('ob_gzhandler');
  
    include "style.css";
  ?&gt;
  </code></pre>
  
  <p>What do you think? Is this a good way to compress js/css files? Is there a better way to do this?
  I'm doing this for a public app. that can be downloaded by anyone. So there will be people on shared hosts with gzip disabled</p>