As Google becomes increasingly concerned with websites’ User Experience (UX), optimizing your site for the platform’s top ranking signals is critical. Among the most important factors to pay attention to are page speed and loading times.
One of the fastest and easiest ways to improve site speed and performance is to enable compression in WordPress. There’s a possibility that your web host automatically enables GZIP compression for you. If not, there are also ways you can take care of this crucial task yourself.
In this post, we’ll explain what GZIP compression is and how it works. Then we’ll discuss how to check and see whether GZIP compression is functioning on your site, and if not, the three methods you can use to enable compression on WordPress. Let’s get started!
In This Article✍️
What Is GZIP Compression? 🗜️
GZIP is a file format and a software application used for file compression and decompression. It was created by Jean-loup Gailly and Mark Adler, and released as a free software replacement for the compression program used in early Unix systems.
As with the Core WordPress software, GZIP was intended for use with GNU (open-source free software). The “G” in “GZIP” is from “GNU”.
GZIP compression does not work on images, and it is a mixed bag when it comes to media files. For example, some image files like MPEGs and WAVs compress well with GZIP. Other file types, such as MP3s, may actually increase in size if you try to compress them.
It’s also important to note that GZIP compression must be enabled on your web server before you can enable file and folder compression. In a bit, we’ll discuss how to determine whether your web server has GZIP enabled.
On the client side, all modern web browsers support GZIP compression, and automatically ask for it when making HTTP requests. This means that you can expect all users to reap the benefits of GZIP compression once you’ve enabled it.
Why Does GZIP Compression Matter?🤷
Compression is commonly encountered in the computer world. Put simply, it is a very handy method of grouping a lot of files together into one smaller file. This helps alleviate some of the issues that arise from having too many large files on your site, which can slow down the loading times of your web pages.
This matters because a slow-loading website can negatively impact UX and impede conversions. In fact, according to Neil Patel, 47 percent of consumers expect a web page to load in two seconds or less. If you’re running an e-commerce business, up to 79 percent of customers say they’re less likely to buy from a website if it provides a poor experience.
How Does Compression Work in WordPress? 🧐
When users go to your website, their browsers download these text files, and will begin rendering the website according to the code contained within them. That code is then translated to something readable and understandable to human users.
However, browsers don’t require all the extra white space and extra formatting used to improve readability for humans. As long as the browser can analyze the code’s content, it can be written in one long block of text.
Therefore, WordPress GZIP compression takes away the formatting that is mainly used for human understanding. Reducing the length of the code in this way also reduces the size of the file containing it.
WordPress GZIP compression can do wonders for your website’s performance, especially when it comes to improving page loading times. If you have ever searched “how to gzip a file”, then this is the article for you.
How to Determine Whether GZIP Compression Is Enabled in WordPress 🧪
Your web host might enable compression in WordPress by default during the account setup process. However, this isn’t always the case. You can check to see if you already have GZIP compression enabled in a couple of different ways.
One of the fastest and easiest methods is to use an online checker such as Base64.Guru’s Gzip Test:
The process to check for GZIP compression is pretty similar regardless of which GZIP test tool you select. All you have to do is provide the URL for your website, and then run the search:
The tool will respond in one of two ways:
- It will tell you that your site is GZIP-enabled, and show you how much space was saved via compression.
- It will tell you that you do not have GZIP enabled.
You can also check to see if your browser receives the content-encoding: GZIP header in the response from the web server. If you’re using Chrome, open your site in a browser tab, then right-click anywhere on the page and select Inspect to open the developer tools.
Next, navigate to Network and click on the home page name. Select the Headers tab, and then scroll down to find the Response Headers section:
There, you’ll see whether or not GZIP compression is enabled.
It’s worth emphasizing that GZIP compression is actually something that you need to enable on the server side, not in WordPress. When you host with companies like GoDaddy or Kinsta, they’ll have this feature already enabled as a part of their standard hosting packages. For some of the other web hosts out there, it’s up to you to enable WordPress GZIP compression.
How to Enable GZIP Compression in WordPress (3 Methods) 🏁
If you’ve determined that WordPress GZIP compression is not yet enabled, there are multiple methods you can use to get it running. Below, we will cover the options for enabling GZIP compression in WordPress, including methods for experienced back-end web developers and newbie WordPress users alike.
1. Enable WordPress GZIP Compression by Manually Editing Your .htaccess File
One of the most common ways to enable WordPress GZIP compression is to edit your .htaccess file. However, this particular method involves modifying your site’s code, which comes with the risk of breaking something. This is a sensitive server file, and one wrong move could cause a lot of problems.
To reduce the likelihood of harming your WordPress website, be sure to save a copy of the original file before making any changes. Also, remember to back up your WordPress website! Once you’ve covered these bases, it’s time to get to work.
The .htaccess file should be in the root folder of your website. The best way to access this file is through a File Transfer Protocol (FTP) client. Once you locate this file, you can either edit it directly or download it to your computer before making changes.
After you locate and open .htaccess, add the following code below the sections marked by the
# BEGIN WordPress and
# END WordPress tags (beyond this, the specific location where you include the snippet doesn’t matter):
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/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/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 no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
Save the file and upload it to your site’s server. When you’re done, run your website through a GZIP compression checker tool (or verify the response headers) as discussed earlier, to make sure you were successful.
Enable GZIP Compression in NGINX or IIS
While most shared hosting plans run on Apache web servers, you may be using something else, such as NGINX or Microsoft’s IIS. Enabling GZIP compression for NGINX web servers is slightly different from the process outlined above.
If you’re running on NGINX (for example, if you’re a Kinsta user), you can enable GZIP compression in WordPress by opening your nginx.conf file and adding the following code:
gzip_disable "MSIE [1-6].(?!.*SV1)";
If you are running Microsoft’s IIS, please see Microsoft’s documentation on how to enable GZIP compression in WordPress.
2. Enable GZIP Compression in WordPress By Contacting Your Hosting Provider
Many web hosts enable WordPress GZIP compression by default, since it offers such noticeable performance benefits. Others, such as SiteGround, only provide their own instructions for enabling WordPress GZIP compression.
If you do not have GZIP compression enabled by default, and you’re not comfortable making changes to your website’s files, you can ask your web host to enable WordPress GZIP compression for you. In general, most web hosts will be willing to assist you with this query when you reach out to their customer support teams.
3. Enable GZIP Compression in WordPress via a Plugin
Of course, if you’re using WordPress, there’s always a plugin that can make the job easier. The caveat? More plugins means more potential security vulnerabilities, and they take up some space on your server.
Regardless, there are a handful of helpful tools that let you easily enable WordPress GZIP compression, including:
WP Super Cache
WP Super Cache is another WordPress caching plugin that offers the option to compress code. It is free to download and use.
To enable WordPress GZIP compression using WP Super Cache, first install and activate the plugin. Then navigate to WP Super Cache > Advanced in your dashboard, and check the box labeled Compress pages so they’re served more quickly to visitors.
W3 Total Cache
W3 Total Cache is considered to be one of the best WordPress caching plugins. It is a robust tool that serves many purposes, including enabling compression.
A note of warning: WordPress newbies can easily break their websites when using W3 Total Cache without proper configuration. However, if you know what you’re doing, you can enable HTTP compression with this plugin by going to the browser cache option and checking the box for HTTP compression.
Enable Gzip Compression
PageSpeed Ninja is a full WordPress performance plugin that you can download for free. One of its features helps you easily enable GZIP compression in WordPress.
To do so, first install and activate the plugin. Then you can navigate to Settings > PageSpeed Ninja > Advanced, and toggle the setting next to Enable compression.
Frequently Asked Questions🤔
Some hosting providers automatically enable compression in WordPress. To see whether compression is enabled on your WordPress site, you can use an online tool such as Base64.Guru’s Gzip Test, or manually search the response headers in Chrome DevTools.
However, if you find that GZIP compression in WordPress is not enabled, there are a few options at your disposal. You can add code to your site’s .htaccess file to manually enable it, reach out to your hosting provider to ask for help, or install a plugin such as WP Rocket or Enable Gzip Compression.
While there are plenty of ways to improve your WordPress site’s speed and UX, GZIP compression is one of the quickest and easiest options. Some hosting providers enable this feature automatically. However, if you see that GZIP compression isn’t active on your WordPress site, you have a few choices.
As we discussed in this post, the three main methods you can use to enable compression on WordPress are:
- Manually edit your site’s .htaccess file to add a few snippets of code.
- Contact your hosting provider to have them enable it, which is recommended if you aren’t comfortable working with code.
- Install a WordPress plugin to enable GZIP compression, such as WP Rocket, PageSpeed Ninja, or Enable Gzip Compression.
Once you’re done, there are several additional tactics you can employ to improve page speeds, such as leveraging image optimization plugins and using a CDN. If you need help with your optimization efforts, just reach out to us here at WP Buffs. We have several Care Plans that suit the needs of website owners, developers, and businesses!
Want to give your feedback or join the conversation? Add your comments 🐦 on Twitter.