check if mod_deflate is enabled

How to Check if mod_deflate is Enabled

mod_deflate is an Apache module that allows you to compress data sent from your web server to client browser. It helps you improve website speed and performance. In this article, we will look at how to check if mod_deflate is enabled on your Apache server. You can use it to check if mod_deflate is working. We will also look at how to enable mod_deflate in case it has not been done already.

How to Check if mod_deflate is Enabled

Here are the steps to check if mod_deflate is enabled in Apache web server.

1. Check if mod_deflate is enabled

Open terminal and run the following command to check the status of mod_deflate

$ sudo apachectl -t -D DUMP_MODULES | grep deflate

The above apachecetl command gets a list of all enabled modules and passes its output to grep command, where we search for string containing “deflate” for mod_deflate module.

If you see the following output it means mod_deflate is enabled. Else it is not enabled.

# deflate_module (shared)

Also read : How to Search in Nano Text Editor in Linux

2. Enable mod_deflate

If mod_deflate is not enabled in your Apache web server then run the following command to enable it


$ sudo a2enmod 


Open Apache configuration file at /etc/apache2/httpd.conf

$ sudo vi /etc/apache2/httpd.conf

Enable mod_deflate by uncommenting the following line, by removing # at its beginning.

#LoadModule deflate_module /usr/lib/apache2/modules/

Also read : How to Create User in MongoDB

3. Configure mod_deflate

We need to also configure mod_deflate to be able to use it effectively. Create a new configuration file for mod_deflate

$ sudo vi /etc/apache2/mods-enabled/deflate.conf

Add the following lines to it.

<ifmodule mod_deflate.c="">
  # 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

In the above code, AddOutputFilterByType specifies the different file types that we want to compress. We are compressing JS, CSS, XML, HTML files above. You can modify it as per your requirement.

DeflateCompressionLevel indicates the level of compress on a scale of 1 to 9, 1 being the lowest level of compression.

DeflateMemLevel specifies the amount of memory to be used by zlib for compression.

DeflateWindowSize indicates the compression window size.

Also read : How to Copy Files to Multiple Directories

4. Restart Apache Server

Restart Apache server to apply changes.

$ sudo apachectl graceful
$ sudo service apache2 restart

Also read : How to Install Joomla in Ubuntu

5. Test Compression

There are many third-party tools like HTTP Compression Test that will automatically check your website and tell if your web server is properly compressing data.

That’s it. mod_deflate wil now be up and running on your Apache server. If you have not enabled mod_deflate yet, it is advisable to do it. It really improves website speed & performance, and consequently increases search engine rankings.

Also read : How to Limit Request Per IP in Apache Server

Leave a Reply

Your email address will not be published. Required fields are marked *