title: How do you set the correct Content-Length header when the webserver automatically compresses output?
body: <p>Following <a href="https://stackoverflow.com/questions/2287576/problem-with-downloads-slow-and-or-fails">my previous question</a>, in which I think I've narrowed my problem down to the bottleneck:</p>
  
  <p>How do I set the correct value for the <code>Content-Length</code> header for a downloadable file, from within PHP, when the webserver (apache) automatically compresses the ouput afterwards?</p>
  
  <p>I'm looking for the most robust/generic solution. I'm not well informed about output compression, but I presume apache has several compression algorithms it can utilize (gzip, etc?). So,  from within PHP, how would I automatically discover what compression the webserver uses, and how can I use this to set the correct <code>Content-Length</code> header value for the filesize of the file (after it's been compressed)?</p>