Using gzip compression on your website can save you a lot of bandwidth and can also improve site speed. You can enable gzip compression on your website by simply adding the following code into your .htaccess file:
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Please note that if your hosting provider does not allow mod_gzip on the server, this code won’t work. After you have added the code in .htaccess, you can check if gzip compression has been enabled with a free online tool called GIDZipTest.