How to Enable GZIP Compression & Speed Up Your WordPress Site

The easiest way to speed up your WordPress site is to remove all unnecessary resources.

The second easiest way to speed it up is to compress all the resources you need.

Enabling GZIP compression on your web server is one of the easiest and most efficient ways to do this. All modern browsers support GZIP compression by default.

However, the server must be properly configured to ensure that the compressed resources are available to users without problems.

This post describes the basics of data compression on the web, what GZIP compression is, its various benefits, and how it can be used to speed up your WordPress site with different server settings.

Are you excited? Let’s unzip!

What is GZIP Compression?

Gzip is a file format and software application used on Unix and Unix-like systems to compress HTTP content before serving it to clients.

This process shrinks files by up to 80%, reduces page load times, reduces bandwidth consumption, and reduces SSL overhead (because there are fewer round trips during the SSL handshake).

File type associated with gzip:

  • .gz – Specifies the file extension compressed by the gzip algorithm.
  • .tar file, tarball-Format for storing multiple files for archiving, but not for compression. You can use Gzip to compress .tar files.
  • .tgz, .tar.gz, .gz files-Identifies gzip-compressed .tar files.

The basics of data compression on the web

<html>
<head>
    <style>
    /* visblues-banner is used on the homepage only */
    .visblues-banner { font-size: 150% }
    .visblues-banner { width: 75% }
</style>
</head>
<body>
    <!-- Visblues banner START -->
    <div>...</div>
    <!-- Visblues banner END -->
    <script>
    VisbluesScripts(); // random scripts used on the page
    </script>
</body>
</html>

Data compression on the web is the process of reducing the amount of data a website sends.

Depending on the type of data (text, images, stylesheets, scripts, fonts), there are different ways to compress the data.

For example, shrinking HTML, CSS, and JavaScript is an easy way to reduce the amount of data sent by the browser.

Here, the minified compresses the text by removing unwanted characters such as comments and spaces from the source code.

The following example of a simple HTML document has three types of content: HTML markup, CSS styles, and JavaScript code.
Each content type has its own syntax and semantics. This HTML document has a total of 357 characters.

<html><head><style>.visblues-banner{font-size:150%;width:75%}</style></head><body><div>...</div><script>kinstaScripts();</script></body></html>

After shrinking, the HTML document is shrunk to 141 characters. This saves 60.50% on the number of characters.

It’s not that easy for the eyes, but it doesn’t matter to the browser. The user will continue to see the same page.

To take advantage of both versions, keep the original document as the “development version”, but shrink all the code before publishing.

Most WordPress performance plugins do this automatically.

uncompresed vs minified jquery
File size comparison

As an example, the uncompressed version of the jQuery 3.5.1 library is more than three times larger than the reduced version of the same file. Similarly, the above compression techniques can optimize other types of content such as images, videos, and fonts.

Such content-specific shrinkage is the first step in optimizing the size of your website’s text-based assets.

But data compression is more than just minimization. Using advanced mathematical techniques, data compression algorithms can further reduce the data size.

One of the best known examples of such a data compression method is GZIP.

It enables efficient data transmission and greatly contributes to making the Internet a promising global communication medium.

Why does GZIP Compression matter?

Downloading simple raw data takes time and affects page load speed.

WordPress websites slow down, even more, when multiple users arrive at the same time.

With GZIP compression, you can efficiently transfer data, increase page load times, and reduce the load on your website hosting.

This is an important step in improving the speed and performance of your website.

Now you might think that GZIP sounds very technical and complicated.

However, there are many WordPress plugins that make it very easy to add GZIP compression to your WordPress website.

Check if GZIP Compression is enabled

In some cases, GZIP may be enabled by your WordPress hosting company. The officially recommended WordPress hosting provider,
Bluehost automatically enables GZIP compression on all new WordPress sites.

To test if GZIP is enabled on your site, simply go to this GZIP tester and enter the URL of your site. If GZIP is working on your site, you will see the message “GZIP is enabled”.

GZIP is enabled
Example of GZIP tester

How to enable GZIP Compression on WordPress

If you need to add GZIP compression yourself, you can add it using one of the following methods:

Enabling GZIP Compression with WPRocket

WP Rocket is the best cache plugin for WordPress.

Very easy to use, it instantly activates all major speed optimization features including GZIP compression.

First, you need to install and activate the WP Rocket plugin.
After activation, your license key will be activated automatically.

To verify this, go to your WordPress administrator’s Settings »WP Rocket page.

A message is displayed informing you that WP Rocket is running.

enable wp rocket

If you are using an Apache server, WP Rocket will automatically enable GZIP compression. Most WordPress web hosting providers use Apache as their server. Do not perform any further steps.

Enabling GZIP Compression with WP Super Cache

WP Super Cache is a free WordPress caching plugin.

This is also a great way to enable GZIP compression on your WordPress site.

First, you need to install and activate the WP Super Cache Plugin. For more information, see the step-by-step guide for installing the WordPress plugin.

After activation, go to Settings »WP Super Cache» Advanced in your WordPress dashboard. Then select the check box next to Compress the page and deliver it to your visitors quickly.

enable wp rocket

Next, you need to scroll down the page and click the Refresh Status button to save your changes. WP Super Cache now enables gZip compression on WordPress websites.

Enabling GZIP Compression with W3 Total Cache

W3 Total Cache is another great WordPress caching plugin. Not as a beginner as WP Rocket, but there is a free version.

This is a good option if the cost of building a WordPress site is added.

First, you need to install and activate the W3 total cache plugin. For more information, see the step-by-step guide for installing the WordPress plugin.

After activation, GZIP compression is automatically activated on your website. To see or change this, go to the Performance »General Settings page on your WordPress dashboard.

we super cache enabled

Scroll down this page to see Browser Cache and make sure the Enable check box is selected.

Be sure to click the Save All Changes button when making changes.

Enable GZIP Compression on WordPress via .htaccess

If your site uses an Apache web server (used by most WordPress hosts), you can enable GZIP compression by adding the following code snippet to your site’s .htaccess file.

<IfModule mod_deflate.c>
# Enables GZIP compression
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 in 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
</IfModule>

Enable GZIP Page Compression via CPanel

Besides enabling GZip page compression at the WordPress level, you can also do this at the server level if possible. This means that all websites hosted on the server are now fully gzip-enabled.

The exact steps for the procedure are as follows:

  1. Log in to CPanel for website hosting.
  2. Click the Website Optimization icon
  3. Select the Compress All Content option
  4. Click Update Settings
  5. The compression test is complete.

Let’s take a closer look at the whole procedure and use the screenshots. Find and click the Website Optimization icon in the
Cpanel.

website optimization cpanel

After visiting the CPanel Optimize website, you can select Compress All Content.

This will prompt the server to gzip the content before sending it to the visitor. Of course, if your WP site is hosted here, you can rest assured that your content is gzipped using WordPress.

gzip enabling with cpanel

Alternatives to GZIP Compression

Compared to GZIP, Brotli is much younger.

Originally released by Google’s software engineers in 2013, it didn’t focus on HTTP compression until 2015. Although it took some time to deploy Brotli 2019 is now supported by all major web browsers.

Like the GZIP, Brotli has different compression levels.

In total, there are 11 different levels that follow a pattern similar to GZIP.

Level 1-Small file savings, but very fast compression speed.

Level 11-Maximum file size savings, but relatively slow compression.

Brotli vs GZIP compression – which performs better?

When it comes to compression speed, Akamai has found it important which “level” to use. GZIP was fast at some levels, while Brotli was fast at some levels.

In the end, Akamai concludes, “With a little tweaking to the Brotli settings, the compression speed actually exceeds that of GZIP, and you can save a lot of money.”

In general, the data seems to indicate that:

  • The Brotli has excellent compression ratio, which makes it excellent for compressing static data.
  • GZIP is good at compressing dynamic data because it often has good compression speeds.

Akamai also points out that if you try the Brotli settings, you can get a compression speed comparable to GZIP while benefiting from better compression ratios.

However, in general, if you’re the average WordPress user, I don’t think you really need to worry about the GZIP and Brotli discussions.
It is important to use some kind of compression.

But for the average WordPress website, you don’t have to worry about using GZIP or Brotli.

Moreover, because it is a nearly universal application in WordPress, GZIP compression is much easier to use, a good starting point for most WordPress users, and you can enjoy the benefits of compression on your website.

Summary

This is just one of the many WordPress tips available in Visblues.

You can easily get incredible savings by enabling WordPress gzip compression, as you can see that it saved up to 81% in
file size.

This is a great way to significantly speed up your website. If you want to make it easier than tinkering with files and code, we recommend using a plugin like WP Rocket.

Newsletter Updates

Enter your email address below to subscribe to our newsletter