Enable Gzip compression to reduce the page size, so there will be fewer resources to download from the webserver. The browser would take less time to display the page, and even the client has to use the fewer data.

The simple process improves site performance, and Google encourages it.

So, the question is how to enable the Gzip Compression in WordPress for faster speed?

What is Gzip Compression?

Gzip compression means compressing data into a smaller file and then zipping it up. The data is accessible after unzipping the file.

In Gzip compression, similar strings are count as one, so all the repetitive data does not need to be sent separately.

How Gzip Works?

It’s all very technical, but let me explain it to you as simply as possible.

When it comes to basic, everything is binary. The universal language — 0 and 1. All the data is in binary language.

For example, this is the data:

1110001111

Now it is in full form. But in the Gzip form it will be:

Three 1, three 0, four 1 — 313040

But yet again, there could be no 3 or 4 in the binary. It is either 0 or 4. Here it goes more technical. The computer assigned a binary value to these 3 & 4 too. And when those binary number creates a repetition, they are also compressed.

This way, a large file becomes incredibly small.

Why should you enable Gzip Compression?

You should enable Gzip compression for the fast loading speed of your site.

When the HTTP sends a request to the webserver for a page, the browser looks for a Gzip file. If they found it, the process takes less time to serve that small file. In the absence of the Gzip file, the whole web page is sent along with the response, and that page takes a long time to render.

How to find if the Gzip compression is enabled?

Tools to check if the Gzip Compression is enabled

PingdomTools

enable gzip compression pingdom tool

GTMetrix

enable gzip compression report on GtMetrix

GiftOfSpeed

GiftForSpeed test for Gzip

Sitechecker.pro

Sitechecker Pro report Gzip

There are lots of tools available for free, only a quick google search away.

If the Gzip is enabled, that’s fine, if not, you should do it.

How to Enable Gzip Compression

Gzip compression has to be enabled with server-side configuration.

Enable Gzip Compression with WordPress Plugin

Most of the quality caching plugin has a function that allows you to enable/disable the Gzip compression on your site.

Caching plugins to enable Gzip:

  • WPRocket
  • W3 Total Cache
  • Pagespeed Ninja
  • WP Super cache

Besides these caching plugins, there are WordPress plugins for this specific job.

Enable Gzip Compression Plugin

However, compression has to be done on the server-side, so these plugins require your hosting permission.

Enable with CDN

If you are using CDN, you can enable Gzip compression. All the popular CDN providers support Gzip compression.

Enable GZIP on Apache

You can enable Gzip on Apache by adding the following lines in the .htaccess file.

Code:


# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Note: Make the backup of the .htaccess file before making any changes.

Enable Gzip on Nginx

You can enable Gzip on Nginx by adding these lines to the Nginx.conf file.

Code:

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;

Note: Make the backup of the Nginx.conf file before making any changes.

Does file compression reduce quality?

Zip format of the file does not reduce the quality of the data. However, there are chances of losing the data, as even the error of the few bits could cause the unzipping of the file. Though the chances of this are low.

Wrapping Up

After enabling the Gzip compression, do check it with any of the above-mentioned tools.

This is a small yet standard web practice, and it improves the speed of the site. If you are not doing it for some reason, you must know that all of your competitors are doing it.

I hope this article helps you in enabling the Gzip compression safely on your site. If there is an issue, leave it in a comment.

Was this post helpful?