Enable mod_deflate on CentOS Apache (slow page load time)

Enable mod_deflate on CentOS Apache (slow page load time)

In our deployment whether mod_deflate is enabled or not , to check this follow below steps.
Chrome/firefox --> Right Click --> Inspect --> Network. 







Reload the home page after login and check the urls coming in Network tab and check the Response headers. Please ensure on your deployment, the responses from apache has content-encoding as "gzip" for all html, js files.  If this is not coming, we need to enable mod_deflate apache module. The expectation is all Ubuntu VM based and container setups should already have this enabled... This could be missing only on CentOs httpd package...



This is for client teams where CentOs based vuSmartMaps is installed.

There is a good chance that mod_deflate is not enabled on the httpd installed on CentOs, so we need to set this up manually. Without mod_deflate http responses will be sent without gzip compression, causing slow page load time.

1. Check if mod_deflate is enabled. 

sudo httpd -D -t DUMP_MODULES | grep deflate

If it's enabled, you will see an entry for "deflate_module". If you dont get an entry, please add the following at the end of /etc/httpd/conf.modules.d/00-base.conf

LoadModule deflate_module /etc/httpd/modules/mod_deflate.so

2. Create a new config file on /etc/https/conf.modules.d/01-deflate.conf and paste the following contents.

<ifmodule deflate_module>
  # compress text, html, javascript, css, xml:
  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
  AddOutputFilterByType DEFLATE image/x-icon
  DeflateCompressionLevel 7
  DeflateMemLevel 8
  DeflateWindowSize 10
</ifmodule>
 
3. Restart apache service
    sudo systemctl restart httpd.service