Skip to content
Advertisement

Compress a manually closed connection AND continue processing

  • I’ve managed to close a PHP connection early and continue processing.
  • I’ve managed to send a compressed response to a client.
  • I have not managed to do both at the same time.

How do send a compressed response and continue processing?

Currently my somewhat minimal test case compresses the server response though it doesn’t close the connection:

JavaScript

Advertisement

Answer

I managed to reduce the code in thanks to a comment by Rush on the ob_get_length documentation page. All three flush commands are required, commenting out any of them results in the page not loading until after sleep(4). I tested this to ensure that the connection closed in the browser, was compressed and then switched over to my file manager to see the file created a few seconds later.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement