Knowledge Base
MilesWeb / Web Hosting FAQ

Enabling Data Compression using the mod_deflate Module

Approx. read time : 2 min

The article explains how you can enable data compression by using Apache’s mod_deflate module. mod_deflate module can be used to compress output from your website that is sent to client browsers. Using data compression reduces page load times and the amount of bandwidth that your site uses.

Note :
All the older versions of Apache used the mod_gzip module for data compression. Practically, the mod_deflate module for Apache 2 provides the same functionality as the mod_gzip module.

# Steps to enable data compression on cPanel managed hosting account

1) Log into your cPanel.

2) Before proceeding to enable compression, first check that zlib.output_compression is enabled by using the Select PHP Version tool.

3) On the cPanel home screen go to the SOFTWARE section and click on Optimize Website.

cPanel - Software

4) On the Optimize Website page, under the Compressor Content heading, select one of the below options :

• Compress All Content: If you wish to compress all of your content then select this option.

• Compress the specified MIME types: To compress the specific content, select this option. In the type box for MIME Types, type the MIME types that you want to compress.

View a complete list of MIME types by visiting :

https://www.iana.org/assignments/media-types/media-types.xhtml

5) Click on Update Settings.

cPanel - Optimize Website

The new settings will be effective immediately. In order to verify that data compression is active, see Determining if compression is enabled below.

# For unmanaged hosting accounts

For the unmanaged hosting accounts, you need to edit the .htaccess file to enable the data compression. Following is a sample configuration that demonstrates one way to enable data compression by a specific file extension:

In this example, the Apache will compress all the files having an extension of .js, .css, .html and .php.

Otherwise, you can also use MIME types to specify which files need to be compressed. Following is a sample configuration that demonstrated one way of doing this :

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

View the complete list of MIME types by visiting :

https://www.iana.org/assignments/media-types/media-types.xhtml

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

You can verify that data compression is active, by viewing Determining if compression is enabled below.

Get more information about the mod_deflate module at :

http://httpd.apache.org/docs/2.2/mod/mod_deflate.html

Also Read :

1) What is CloudFlare Railgun and How to Enable it on Your Website?

2) How To Optimize Drupal For An Efficient Performance?

Sonam Wagh
With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.
Need help? We’re always here for you.
Register Your Free Domain Name
OFFER EXPIRES IN
04
min
59
sec