Hi,
Below are the steps I have followed to enable gzip compression for a site.
1)First enable mod_deflate module for apache on the server
This can be done by using easy apache on the cpanel server. Check if it is enabled or not, by using the command
httpd -l |grep -i deflate
2)Then open the .htaccess configuration file in the website's document root and add the following code on it.
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
3)Also we need to add the gzip compression settings in php.ini of the server
If you are using suphp, then Copy the php.ini to the document root of the wensite
Then add the compression configuration as below
Below are the steps I have followed to enable gzip compression for a site.
1)First enable mod_deflate module for apache on the server
This can be done by using easy apache on the cpanel server. Check if it is enabled or not, by using the command
httpd -l |grep -i deflate
2)Then open the .htaccess configuration file in the website's document root and add the following code on it.
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
3)Also we need to add the gzip compression settings in php.ini of the server
If you are using suphp, then Copy the php.ini to the document root of the wensite
Then add the compression configuration as below
output_handler = Off zlib.output_compression = On zlib.output_handler = ob_gzhandler
That's it. Now check if gzip is enabled or not using the site
http://checkgzipcompression.com