I am tyring to stop nginx from gzipping a single PHP request. I already have the following:
@ini_set('zlib.output_compression', 'Off');
@ini_set('implicit_flush', 1);
header('X-Accel-Buffering: no');
According to everything I have found, that X-Accel-Buffering
alone should disable gzip, however when I load this page from a browser, I can still see the header:
Content-Encoding:gzip
I'm using php7-fpm, nginx 1.10.1, debian8
EDIT:
I did a test using sleep() to delay the output. It looks like header('X-Accel-Buffering: no');
IS working, however it only prevents buffering and not gzipping. I guess gzipping is working as a stream somehow.
I can see that if I output 1,000 bytes, looping over an echo statement with 1 char each, the browser receives about 11kb. If i echo a str_rep x 1000, then much less data is sent. There must be some overhead there.
Regardless, I need to disable gzip so that I can send a large amount of content and measure the download time. If it's gzipped, I don't know what the actual throughput is.
Nginx will not run gzip filter if Content-Encoding
header found in answer. So, you can set Content-Encoding: identity
header on backend, and nginx will pass it to client without gzip process. identity
means "not encoded".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With