Last Updated on 4 weeks by Sachin G

Most of the users are having issues with website loading, the load time is very high or the website feels sluggish. There’s a simple, server-side trick that can speed it up instantly — Gzip compression on your Apache server. There are several methods to speed up a website, one of them is Gzip compression, and it is the most popular method to load fast by compressing the page size of your site.

Now these days majority of websites use compression, delivering the content to the latest browsers, which support compression. It is useful when we use HTML text, JS, JavaScript, like images already compressed. So it will save bandwidth and then the website gets more responsive.

By compressing your website’s files (HTML, CSS, JS), Gzip helps reduce page load times dramatically. This guide will walk you through how to enable Gzip compression in Apache, explain how it works, and share some real-world insights to make sure you get the best performance possible.

What Is Gzip Compression in Apache?

Gzip compression is a method of reducing the size of files sent from the server to the browser. On an Apache web server, it’s typically implemented using the mod_deflate module.

When a user visits your website:

  • Apache compresses the files
  • The browser receives smaller data
  • The page loads faster

This leads to improved Apache server performance and website speed optimization — both crucial for user experience and SEO.

How to Enable Gzip Compression in Apache (Step-by-Step)

Here’s how to get it working quickly, whether you’re on Ubuntu, using .htaccess, or configuring httpd.conf.

Step 1: Enable mod_deflate Module

Mod_deflate apache module will installed by default in apache server . Below is the command to enable mod_deflate is installed and enabled .

sudo a2enmod deflate
sudo systemctl restart apache2

To check for Debian Based System :

 apache2ctl -t -D DUMP_MODULES | grep  mod_deflate

For Linux ( CentOS/Red Hat ) :

httpd -t -D DUMP_MODULES | grep deflate_module

 

Output will be like below.

deflate_module (shared)

Syntax OK

Step 2: Add Gzip Configuration

Option A: For .htaccess users

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

Option B: For apache2.conf or httpd.conf

<IfModule mod_deflate.c>
  DeflateCompressionLevel 9
  AddOutputFilterByType DEFLATE text/html text/css application/javascript
</IfModule>

How to Check If Gzip Is Enabled on Apache Server

There are so many sites online which provide to help test whether mod_deflate or gzip compression is working or not .Find below one of the online test url.

You can verify compression is working by using:

Personal Insight: Scaling with Gzip Compression

I tested for my same site , Apache server where enabling gzip cut homepage compressed site is from 24.8 KB to 5.8 KB.

Enter the URL and click on the “Test” button.Below is the example of online test snapshot.

mod_deflate_test_techtransit

Apache Gzip Compression Not Working? Here’s What to Check

Many users hit roadblocks enabling gzip. If Apache gzip compression is not working, check for:

  • Missing mod_deflate module
  • Incorrect AddOutputFilterByType syntax
  • Server caching headers preventing compression
  • Conflicts with CDNs or reverse proxies

Lesson from here : During one setup, enabling gzip on Apache Ubuntu server didn’t work until an unused CDN setting was disabled. The fix was simple — but only obvious in hindsight.

Apache Gzip vs Deflate — What’s the Difference?

While mod_deflate is the module that enables gzip in Apache, Deflate is a specific compression algorithm. Gzip uses Deflate under the hood — so in most Apache setups, they’re essentially the same thing.

FAQ: Gzip Compression in Apache

1. What if gzip compression doesn’t work?

Check if mod_deflate is active, rules are written properly, and no CDN or reverse proxy is interfering.

2. Is gzip compression safe to use?

Yes, it is widely used across the web and does not affect file content integrity.