Right now I\'m trying to serve CSS and JS files from a server that won\'t let me enable mod_gzip or mod_deflate. So I wrote a small PHP script to
mod_gzip
mod_deflate
You need to first do the entire gzip and measure the result (either holding the contents in memory, or writing them to disk as you compress and then stat'ing the gzipped file), then write the Content-Length header and then send the file contents.
Or use chunked transfer encoding.