diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index d73b803f3..fe360d442 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -608,11 +608,10 @@ class Grav extends Container // Unfortunately without FastCGI there is no way to force close the connection. // We need to ask browser to close the connection for us. - // With zlib.output_compression enabled, PHP handles compression automatically. - // We cannot set Content-Length when compression is active (size unknown until compressed). - if (!$config->get('system.cache.gzip') && !ini_get('zlib.output_compression')) { - if ($config->get('system.cache.allow_webserver_gzip')) { - // Let web server to do the hard work. + // Check if external compression is active (e.g., zlib.output_compression in php.ini). + if (!ini_get('zlib.output_compression')) { + if ($config->get('system.cache.gzip') || $config->get('system.cache.allow_webserver_gzip')) { + // Let web server handle compression. header('Content-Encoding: identity'); } elseif (function_exists('apache_setenv')) { // Without gzip we have no other choice than to prevent server from compressing the output. diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 70620f300..8f2010387 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -345,12 +345,6 @@ class InitializeProcessor extends ProcessorBase // Use output buffering to prevent headers from being sent too early. ob_start(); - if ($config->get('system.cache.gzip')) { - // Try to use zlib.output_compression instead of ob_gzhandler (more robust) - if (!ini_get('zlib.output_compression') && !headers_sent()) { - ini_set('zlib.output_compression', '4096'); - } - } $this->stopTimer('_init_ob'); }