title: PHP + gzip: close connection and continue executing
body: <p>I am responsible for the backend portion of an API, written in PHP, which is primarily used by a Flash client. What happens right now is: the Flash client makes a call, the backend loads the necessary data, does any necessary processing and post processing, logging and caching and then returns the result to the client.</p>
  
  <p>What I would like to have happen is return the data to the client as soon as possible, close the connection, and then do all the stuff that the client doesn't have to care about. This could make the API seem much more responsive. Following the suggestions here:</p>
  
  <p><a href="http://php.net/manual/en/features.connection-handling.php" rel="noreferrer">http://php.net/manual/en/features.connection-handling.php</a></p>
  
  <p>actually works, except that I have to turn off gzip encoding in order to make it work, which isn't very practical. We use mod_deflate in apache, so a solution that works with that would be ideal, but I would also consider a different method to gzip our content if that is necessary.</p>
  
  <p>It <em>seems</em> like there should be a way to let Apache know "I've sent you all the data I'm going to send," but I can't seem to find anything like that.</p>
  
  <p>For those wondering, yes I can flush the results early, but the Flash client will not process them until the connection is closed.</p>