From 007b168ad97b095bf9c6bdec81d10bdfcaa7b517 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 25 Dec 2025 21:41:20 -0700 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20do=20internal=20gzip,=20rely=20?= =?UTF-8?q?on=20webserver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Miller --- system/src/Grav/Common/Grav.php | 9 ++++----- .../src/Grav/Common/Processors/InitializeProcessor.php | 6 ------ 2 files changed, 4 insertions(+), 11 deletions(-) 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'); }