How to enable gZIP compression for your pages?

GZIP compression improves the performance of your website and decreases its loading time. When a visitor makes a request for your website, the server compresses the requested page, significantly reducing its size, and transfers it to the customer's computer. On the visitor's end the file is being decompressed and visualized. The time needed for file compression is much less than the time to transfer a big file over the Internet, thus compression enhances the performance of a website.

To enable GZIP compression for your text, html, JavaScript, CSS and XML you can add these lines inside your website's  .htaccess file:
1
2
3
4
5
6
7
8
9
10
11
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
You can edit the .htaccess file with the File Manager in cPanel or via FTP.

Some applications also have internal support to compress their pages. For example, in Joomla you can turn on the Gzip compression from Global Configuration -> Server -> Gzip Page Compression set to Yes.