How to enable GZIP compression?

From PheonixSolutions
Jump to navigation Jump to search

Please follow the below steps to enable GZIP at apache level

Step-1:- Enable Gzip Module using the below command.

sudo a2enmod deflate


Step-2:- Configure Gzip Compression. Add below one in /etc/apache2/sites-enabled/

 
<Directory /var/www/html/>
<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/plain text/xml 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>
Header append Vary User-Agent env=!dont-vary
</Directory>


Step-3:- After adding restart apache2 with the below command.

 systemctl apache2 restart

Step 4 – Testing Compression
Please verify the compression with the links below. Please find the output in the screenshot provided below.

 http://checkgzipcompression.com/
http://www.whatsmyip.org/http-compression-test/


For reference please follow below link

https://tecadmin.net/enable-gzip-compression-apache-ubuntu/

  sudo a2enmod deflate