diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 6351793e1..38ab04511 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -615,7 +615,8 @@ class Dispatcher extends Object { */ function _deliverAsset($assetFile, $ext) { $ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false); - if ($ob && Configure::read('Asset.compress')) { + $compressionEnabled = $ob && Configure::read('Asset.compress'); + if ($compressionEnabled) { ob_start(); ob_start('ob_gzhandler'); } @@ -642,11 +643,13 @@ class Dispatcher extends Object { if ($ext === 'css' || $ext === 'js') { include($assetFile); } else { - ob_clean(); + if ($compressionEnabled) { + ob_clean(); + } readfile($assetFile); } - if (Configure::read('Asset.compress')) { + if ($compressionEnabled) { ob_end_flush(); } }