실행시 설정

이 함수의 작동은 php.ini 설정에 영향을 받습니다.

zlib 확장은 브라우저가 지원한다면, 페이지를 전송할 때 압축할 수 있는 옵션을 제공합니다. 설정 파일 php.ini에 세가지 옵션이 존재합니다.

Zlib 설정 옵션
이름 기본값 설정권한 변경점
zlib.output_compression "0" PHP_INI_ALL PHP 4.0.5부터 사용할 수 있습니다.
zlib.output_compression_level "-1" PHP_INI_ALL PHP 4.3.0부터 사용할 수 있습니다.
zlib.output_handler "" PHP_INI_ALL PHP 4.3.0부터 사용할 수 있습니다.
PHP_INI_* 모드에 대한 상세와 정의는 Where a configuration setting may be set를 참고하십시오.

위 설정 지시어에 대한 간단한 설명입니다.

zlib.output_compression boolean/integer

페이지 압축의 사용 여부. 이 옵션을 php.ini나 아파치 설정에서 "On"으로 지정하면, 브라우저가 "Accept-Encoding: gzip"이나 "deflate" 헤더를 보냈을때, 페이지를 압축합니다. "Content-Encoding: gzip"(혹은 "deflate")과 "Vary: Accept-Encoding" 헤더을 출력에 추가합니다. 실행시에는 출력 전송을 시작하기 전에만 설정할 수 있습니다.

boolean "On"/"Off" 외에 정수값을 지정하여, 출력 버퍼 크기를 설정할 수 있습니다. (기본값은 4KB) (default is 4KB).

Note:

'On'으로 지정했을 때, output_handler는 zlib.output_handler를 사용하지 말고, 비어있어야 합니다!

zlib.output_compression_level integer

출력 압축에 사용하는 압축 레벨.

zlib.output_handler string

zlib.output_compression을 활성화 했을 때, 추가 출력 핸들러를 지정할 수 없습니다. 이 설정은 output_handler와 동일한 다른 명령입니다.

add a note add a note

User Contributed Notes 6 notes

up
1
finlanderid at gmail dot com
9 years ago
Does anyone find these two statements contradictory? Am I not understanding something, or are these statements actually contradicting each other?

Statement ONE from output_handler:
"output_handler must be empty if this [zlib.output_compression] is set 'On' ! Instead you must use zlib.output_handler."

Statement TWO from zlib.output_handler:
"You cannot specify additional output handlers if zlib.output_compression is activated ..."

Statement ONE says you have to use zlib.output_handler, if zlib.output_compression is turned ON. Statement TWO says that, if zlib.output_compression is turned ON, you cannot use zlib.output_handler.

what the heck?
up
-6
scott at pawprint dot net
12 years ago
In the hopes this will help others - a hard to spot gotcha when implementing zlib.output_compression. if you use flush() anywhere in your script (even right at the end) the compression won't work - you need to let that happen automatically or it ends up being sent uncompressed.
up
-4
Anon
4 years ago
Because of possible BREACH attacks when using output compression cross-site scripting should be disallowed. This can be achieved with the same-site cookie attribute:

https://www.sjoerdlangkemper.nl/2016/04/14/preventing-csrf-with-samesite-cookie-attribute/

https://caniuse.com/#feat=same-site-cookie-attribute
up
-9
galaxy
8 years ago
finlanderid at gmail dot com,

you are mixing two separate things and consider them to be the same thing, hence the confusion.

There are two output_handlers:

1. http://php.net/manual/en/outcontrol.configuration.php#ini.output-handler

2. http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-handler

Now, if you re-read your quotes again with this information it won't be confusing anymore :)
up
-6
pacerier+php dot net at gmail dot com
6 years ago
@finlanderid, Exactly. As output_handler and zlib.output_handler cant be both set (as per ""<output_handler must be empty if this is set 'On'>""), "different order" refers to?
up
-21
Nathan
12 years ago
Apparently, there is a bug in certain versions of PHP with setting zlib.output_compression to "On" via ini_set:

<?php
ini_set
("zlib.output_compression", "On");
?>

In some cases, it does not send the Content-type header and browsers won't know to decompress the contents before displaying. Instead, you can set it to the buffer size, which sends the correct header:

<?php
ini_set
("zlib.output_compression", 4096);
?>
To Top