title: json gzip compression with php
body: <p>I use this way to send serve a json file from my server.</p>
  
  <pre><code>$data = file_get_contents('cache/file.json');
  
  ob_start('ob_gzhandler');
  
  // Output as normal
  echo ($data);
  </code></pre>
  
  <p>cache/file.json is not gzip compressed (plain json, without spaces the whole
  file is one long row).</p>
  
  <p>I'm thinking Instead of gzipping the file everytime it is requested.
  Should I store it as a gzipped file</p>
  
  <pre><code>$gzjson = gzencode($data, 9);
  file_put_contents('gzcache/file.json', $gzjson);
  </code></pre>
  
  <p>So I will minimize the server load? 
  The idea is to gzip it and everytime the file is requested
  just serve the already gzipped file and not gzip it every time it's requested.</p>
  
  <p>Does anyone think this is a good idea?</p>