Welcome Guest, Not a member yet? Register   Sign In
CI 4 Output Compression
#8

(09-02-2021, 12:19 AM)stopz Wrote: In your Controller you can call for negotiator service to set gzip encoding.
PHP Code:
service('negotiator')->encoding(['gzip']); 

In my case i don't have to set this in controller. Just with the .htaccess and mod_deflate.so enable to make it work.
Thanks.
But still is there no other way to set compression without changing apache module?
I found a way to force gzip/compression without changing apache module but not sure if it's a good practice.
I edit Events.php file in config like this :

Code:
if(!ob_start("ob_gzhandler")){
if (ini_get('zlib.output_compression'))
{
throw FrameworkException::forEnabledZlibOutputCompression();
}

while (ob_get_level() > 0)
{
ob_end_flush();
}

ob_start(function ($buffer) {
return $buffer;
});
}
Reply


Messages In This Thread
CI 4 Output Compression - by [email protected] - 06-18-2021, 07:23 AM
RE: CI 4 Output Compression - by InsiteFX - 06-19-2021, 12:51 AM
RE: CI 4 Output Compression - by InsiteFX - 06-19-2021, 09:02 PM
RE: CI 4 Output Compression - by stopz - 09-02-2021, 12:19 AM
RE: CI 4 Output Compression - by nc03061981 - 12-10-2021, 08:07 PM
RE: CI 4 Output Compression - by [email protected] - 12-12-2021, 05:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB