Performance WordPress

How To Enable GZIP Compression In WordPress

How To Enable GZIP Compression In WordPress

You’re probably already familiar with compression if you’ve worked with computers for any length of time. For those who aren’t familiar, compression is a powerful technique for condensing a large number of files into a single, much smaller (and more readily transportable) file – which, in the case of websites, means much quicker page load speeds. I’ll explain how gzip compression works and how to enable gzip compression on your own WordPress-powered website in this article.

Check Out – VPS Hosting vs Dedicated Hosting for a WordPress Website

Gzip Compression and Its Effects

Let’s take a look at what compression is and how it may assist before going on to how to apply it.

Almost all current websites employ a combination of HTML, CSS, and JavaScript, which are created by programmers in a logical, universally understood manner. As a result, there is usually always a significant amount of overhead that serves no purpose other than human reading. In addition, most programmers will employ a variety of design patterns and common components, resulting in a significant degree of duplication.

Compression techniques like gzip take use of text’s patterns and repetitions to make data storage more efficient. Consider the following scenario.

To make the text in it bold, use the following HTML code:

<strong>this is bold</strong>

The compressed version of this is actually pretty long: eNqzKS4pys9LtyvJyCxWAKKk/JwUG32oIC8XALn8Cuo=. However, take a look at what happens when we compress the following:

<strong>this is bold</strong>
<strong>this is bold too</strong>

The compressed version is eNqzKS4pys9LtyvJyCxWAKKk/JwUG32oIC+XDRZphZL8fCQlACNDF0U=. Even though the original text is more than double the size, the compressed version is actually only 16 characters more — a whopping 32% reduction in size, which means less to load and a faster website.

How To Enable gzip Compression for WordPress

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

And that’s it — all done! Your text-based content, such as HTML, CSS and JavaScript, should now be transmitted in its gzip compressed form.

Testing after enabling Gzip compression

One of the quickest (and most fascinating) methods to verify whether or not a site’s files are gzip compressed is to use the amazing GTMetrix site testing tool.

If everything is operating well (and you may need to clear your site’s cache and/or wait a few minutes for changes to take effect), you should see the following in the ‘Waterfall’ section of your GTMetrix results:

enable gzip compression gtmetrix results

Check Out – How to Enable Browser Caching in WordPress

Conclusion

Gzip compression is a simple performance improvement that you can make (or have made) to your site, whether it’s powered by WordPress or not. You may be losing out on a substantial speed improvement if you don’t activate it.

If you are still struggling to enable gzip compression on your WordPress website, contact us now and we will do it for you – Get a Quote

Leave a comment

Your email address will not be published.