# Enabling data compression using the mod_deflate module

> Turn on mod_deflate compression in .htaccess so your pages load faster and use less bandwidth, and check that it works.

Source: https://helpcenter.ruachost.com/developers/web-servers/enabling-data-compression-using-the-mod-deflate-module/

The **mod_deflate** module in Apache allows you to compress output before sending it to client browsers. On **ruachost.com**, enabling compression reduces page load times and bandwidth usage, improving overall site performance.

## Why Use mod_deflate?

- Speeds up website loading by reducing file sizes.
- Saves bandwidth costs.
- Improves SEO rankings (Google favors faster sites).
- Works seamlessly with most modern browsers.

## Steps to Enable Compression

### Managed Hosting Accounts (cPanel)

1. Log in to **cPanel**.
2. Go to **Software → Optimize Website**.
3. Under **Compress Content**, choose one of the following:

   - **Compress All Content** – compresses everything.
   - **Compress Specified MIME Types** – compresses only certain file types.
4. Click **Update Settings**.
5. Test compression using tools like GiftOfSpeed Gzip Test.

### Unmanaged Hosting Accounts

Edit your `.htaccess` file to enable compression.

### Option 1: By File Extension

```

  
    SetOutputFilter DEFLATE
  

```

### Option 2: By MIME Type

```

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

```

- This compresses HTML, CSS, JavaScript, XML, and plain text files.
- To disable compression, comment out or remove the relevant lines.

## Verifying Compression

1. Visit GiftOfSpeed Gzip Test.
2. Enter your domain name.
3. The tool will confirm whether compression is active.

> **Important Notes:**
- Older Apache versions used **mod_gzip**; `mod_deflate` replaces it in Apache 2+.
- Compression is already enabled on shared hosting accounts by default.
- For VPS or dedicated servers, Ruachost support can install `mod_deflate` if missing.
- Avoid compressing already compressed files (e.g., images, PDFs, ZIPs).
