How to enable data compression using the mod_deflate module

This article describes the way to enable data compression using Apache's mod_deflate module. You’ll use the mod_deflate module to compress output from your website that’s sent to client browsers. Using data compression can reduce page load times and the amount of bandwidth your site uses.

cPanel (managed) hosting accounts

To enable data compression on cPanel-based hosting accounts, follow these steps:

1. Log in to cPanel.

2. Before enabling compression check to see that zlib.output_compression is enabled by using the Choose PHP Version tool

3. In the SOFTWARE section of the cPanel home screen, click Optimize Website:

     

4. On the Optimize Website page, under Compress Content, choose one of the following options:

  • Compress All Content: Choose this option if you want to compress all of your content.
  • Compress the required MIME types: Choose this option if you want to compress specific sorts of content. In the MIME Types text box, type the MIME types that you want to compress.


5. Click Update Settings. The new settings take effect immediately. To verify that data compression is active, please see Determining if compression is enabled below.

Unmanaged hosting accounts

For unmanaged hosting accounts, you must edit the .htaccess file to enable data compression. The following sample configuration demonstrates a method to enable data compression by specifying file extensions:



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

Alternatively, you’ll use MIME types to specify which files to compress. The following sample configuration demonstrates a method to do this:



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

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

To verify that data compression is active, please see Determining if compression is enabled below.

Determining if compression is enabled

To check if data compression is enabled on your site, type your domain name in the text box, then click CHECK. The site tells you whether or not compression is currently enabled.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How can I change a database password on cPanel?

Changing MySQL database password via cPanel You can change your database’s password by...

How can I change my PHP version on cPanel?

Changing PHP version via cPanel Your Hosting Account's PHP version can be changed at any time,...

How can I create a new MySQL database in cPanel?

Creating a new MySQL database at Servers GATE using cPanel   You can easily create a new MySQL...

How can I locate my MySQL database details on cPanel?

Locating your MySQL database details via cPanel You can easily locate your MySQL databases...

How can I set up a redirect on cPanel?

Creating a redirect on cPanel Your hosting redirects can be easily managed with the assistance...