How to determine the Content-Length of a gzipped file?

前端 未结 3 1790
半阙折子戏
半阙折子戏 2020-12-10 12:35

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

3条回答
  •  温柔的废话
    2020-12-10 13:05

    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.

提交回复
热议问题