Knowledge Base

How to enable data compression using the mod_deflate module

This article describes how to enable data compression by configuring Apache's mod_deflate module in an .htaccess file.

The mod_deflate module is already installed (but not enabled) on shared hosting accounts, and we can install it on managed VPS and dedicated servers as well at your request. If you need further assistance, please open a support ticket with our Guru Crew on the Customer Portal at

Using data compression with the Apache mod_deflate module

You can use the Apache mod_deflate module to compress output from your web site that is sent to client browsers. Using data compression can reduce page load times and the amount of bandwidth your site uses.

Older versions of Apache used the mod_gzip module for data compression. In practice, the mod_deflate module for Apache 2 provides the same functionality as the mod_gzip module.

To enable data compression with the mod_deflate module, use a text editor to edit the .htaccess file. The following sample configuration demonstrates one way to enable data compression by specifying file extensions:

<IfModule mod_deflate.c>
    <filesMatch "\.(js|css|html|php)$">
        SetOutputFilter DEFLATE

In this example, Apache compresses any file that has an extension of .js, .css, .html, or .php.

Alternatively, you can use MIME types to specify which files to compress. The following sample configuration demonstrates one way to do this:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/javascript

In this example, Apache compresses any file that uses one of the MIME types referenced by the AddOutputFilterByType directive.

To disable data compression, you can delete the relevant lines in the .htaccess file, or comment them out by preceding each line with #.

More Information

For more information about the mod_deflate module, please visit