title: PHP gzipping JSON, saving to memcache... Node.js serving - proper headers?
body: <p>In PHP I am doing something like:</p>
  
  <pre><code>$gzdata = gzencode(json_encode($data), 9);
  $mc-&gt;set("latest", $gzdata);
  </code></pre>
  
  <p>So I pull my associative array from the DB, I turn it to JSON, Gzip it and store to memcache</p>
  
  <p>In my Node.js I read the memcached entry and serve it (where client is memcache client)</p>
  
  <pre><code>client.get('latest', function(err, response) {
              if (err) { console.log("GET", err.type ); } 
              else{
                  result.writeHead(200,{
                      "Content-Type": "application/json",
                      "content-encoding":"gzip"
                  });
  
  
                  result.end(response['latest']);
              }
          });
  </code></pre>
  
  <p>I am getting </p>
  
  <blockquote>
    <p>Content Encoding Error</p>
  </blockquote>
  
  <p>on the page</p>
  
  <blockquote>
    <p>The page you are trying to view cannot be shown because it uses an
    invalid or unsupported form of compression.</p>
  </blockquote>
  
  <p>I cannot even check the headers in FB... any ideas what am I doing wrong?</p>