Karal Max
May 17, 2016
The mod_deflate module provides the DEFLATE output filter that allows the output from your server to be compressed before being sent to the client over the network. mod_deflate is the replacement of mod_gzip which was used with an older version of Apache....
By default, a mod_deflate module is enabled in Apache. To make sure that it is enabled, check the following line in the Apache configuration file.
LoadModule deflate_module modules/mod_deflate.so
Now edit your apache configuration and add the extensions you want to compress.
nano /etc/httpd/conf/httpd.conf
Add the following lines at end of the file
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
Restart Apache service,
## CentOS ##
sudo service httpd restart
## Ubuntu ##
sudo /etc/init.d/apache2 restart
Add the following configuration in Apache Virtual Host to enable gzip compression for your website. You can also add this code in the website's .htaccess file in the site root.
AddType application/x-javascript .js
AddType text/css .css
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent env=!dont-vary
We have enabled gzip compression, let’s use one of the online tools below to verify gzip is working correctly.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!