---
title: "An Introduction to gzip / mod_deflate"
description: "mod_deflate is an Apache module that can be used to compress data using gzip compression before sending it to the user. For bandwidth intensive websites, using this feature can offer a benefit, as..."
url: https://www.inmotionhosting.com/support/website/how-to-enable-gzip-moddeflate/
date: 2012-01-05
modified: 2025-03-10
author: "Brad Markle"
categories: ["Website"]
type: post
lang: en
---

# An Introduction to gzip / mod_deflate

![mod_deflate Gzip Compression](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/gzip-mod_deflate-1024x538.jpg)

**mod_deflate** is an Apache module that can be used to **compress data using gzip compression** before sending it to the user. For bandwidth intensive websites, using this feature can offer a benefit, as the server is compressing data before sending it you will be using less bandwidth. The major drawback to using mod_deflate however is that the server may need to use more resources to compress each file and this in turn can cause performance issues on older servers. As our shared accounts included unlimited bandwidth, using mod_deflate to reduce bandwidth usage is not usually a concern for shared users.

It’s important to understand that **gzip** compression does not reduce resource usage on a server, nor is it guaranteed to reduce page load times for your website. To reduce possible resource usage and reduce page load time, a better solution is a caching option for your site. There are caching modules or settings for sites created with a content management system (CMS) such as [WordPress](https://www.inmotionhosting.com/support/edu/wordpress/plugins/wp-super-cache/), [Joomla](https://www.inmotionhosting.com/support/edu/joomla/joomla-4/how-to-enable-caching/), [Drupal](https://www.inmotionhosting.com/support/edu/drupal/drupal-performance-optimization/), etc.

**Please note:** Due to the performance issues that can be caused by mod_deflate, it should not be used on older shared servers. Contact Live Support for more information about your hosting account and how to migrate to a new [Linux server](/vps-hosting/linux-vps) hosting plan.

- [How to Install mod_deflate](#install)
- [How to Use mod_deflate](#use)
  - [Enabling mod_deflate (gzip Compression) in cPanel](#cpanel)
  - [Enabling mod_deflate (gzip Compression) in .htaccess](#htaccess)
- [How to Test if mod_deflate is Working](#test)
  - [Issues with PHP 7](#issues)

## How to Install mod_deflate

The mod_deflate Apache module is already installed on our shared hosting servers.

cPanel VPS and dedicated server administrators can install the HTTP compression module in WebHost Manager (WHM).

1. [Log into WHM as root](https://www.inmotionhosting.com/support/edu/whm/log-into-whm/).
2. On the left select “EasyApache 4.”
3. Beside “Currently Installed Packages,” select “Customize.”
4. Select “Apache Modules.”
5. Search for “mod_deflate.”
6. Select the mod_deflate toggle switch to turn it blue.![Installing mod_deflate in EasyApache4](https://www.inmotionhosting.com/support/wp-content/uploads/2012/01/whm-mod_deflate-1024x455.png)
7. Select “Review.”
8. Select “Provision.”

Cloud server administrators can use the following command to see if the Apache module is already installed and enabled:

apachectl -M | grep deflate

If the output states “deflate_module (shared)” then it is installed.

## How to Use mod_deflate

To use mod_deflate, you have two options:

- Use the Website Optimization option in cPanel
- Add a few lines to your .htaccess file

### Enabling mod_deflate (gzip Compression) in cPanel

Under **Software/Services** in your cPanel click on the **Website Optimization** icon.

![Optimize Website cPanel App for mod_deflate](https://www.inmotionhosting.com/support/wp-content/uploads/2012/01/cpanel-optimize-website-1024x327.png)

Select **Compress all content** or specific MIME types. To limit which types of content are compressed, choose **Compress the specified MIME types** and input the particular MIME types you want to compress.

If you specify particular MIME types, it is best not to add image, video, audio, PDF or other types of binary files. These file formats are already compressed, so it is not necessary to compress these further.

Once you have chosen your settings, click **Update Settings** to save your changes and enable gzip compression on your account.

To turn off gzip compression, select **Disabled** on the Website Optimization page and click **Update Settings**.

### Enabling mod_deflate (gzip Compression) in .htaccess

Edit your [.htaccess file](/support/website/htaccess-file/) and add the following code:

AddOutputFilterByType DEFLATE
text/text
text/html
text/plain
text/xml
text/css
application/x-javascript
application/javascript

## How to Test if mod_deflate is Working

There are several sites online that you can use to help test whether mod_deflate is working for your site or not. One site we found rather easy to use is [https://www.whatsmyip.org/http-compression-test/](https://www.whatsmyip.org/http-compression-test/).

All you need to do is enter your domain and click the “Test” button. Below we have showed before and after screenshots that indicate whether mod_deflate is enabled.

![whatsmyip.org HTTP compression test unsuccessful](https://www.inmotionhosting.com/support/wp-content/uploads/2012/01/website_gzip_when-mod_deflate-disabled-1024x151.png)*URL compression test failed*

![whatsmyip.org HTTP compression test successful](https://www.inmotionhosting.com/support/wp-content/uploads/2012/01/website_gzip_when-mod_deflate-enabled-1024x151.png)*URL compression test successful*

### Issues with PHP 7

Various users have reported issues involving the cPanel *Optimize Website* button and performance with PHP files. This seems to have affected websites using PHP version 7 and up. If you are having trouble using the compression features available from cPanel, you can try making these modifications in your `php.ini` file.

output_handler = Off
zlib.output_compression = On
zlib.output_handler = ob_gzhandler

**Reliable Shared Hosting for Growing Businesses**

Get the performance your business website demands with NVMe SSD storage, industry-standard cPanel management, and direct access to hosting experts whenever you need assistance.

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Free Website Migration     ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)24/7 Human Support     ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)100% Money-Back Guarantee

[Shared Hosting](https://www.inmotionhosting.com/shared-hosting?mktgp=t&irgwc=1&affiliates=5001860&utm_campaign=Jumbotron&utm_source=supportcenter&utm_medium=cta&utm_term=shared-cta2)
