Search code examples
phpcodeigniterapache2gzipmod-deflate

Using Gzip/Deflate with Codeigniter for better performance


I'm using Codeigniter a PHP framework and apache2.
I have enabled Gzip and deflate mod in apache2 and its showing phpinfo(). When I run Yslow it shows "Grade F on Compress components with gzip".
Even I changed the config.php of Codeigniter
$config['compress_output'] = TRUE;

but there is no effect. Is any thing I'm missing.


Solution

  • you should enable mod_deflate just for CSS, html, js.

    Ex:

    <ifmodule deflate_module>
        DeflateCompressionLevel 1
        DeflateBufferSize 8096
        DeflateMemLevel 8
        DeflateWindowSize 8
    
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/xml
    </ifmodule>
    

    Because images or videos are already compressed and also they take a lot of time to try to compress. Also there is a compress option on php.ini

    Maybe it helps...