As Google becomes more and more focused on improving the user’s experience of websites, web developers are paying attention. They know that user experience is boosted by fast loading times and good page speeds. These factors became significant search ranking factors during the summer of 2018, which is way back in the murky mists of time now. If you didn’t know that, then chances are you’ll be getting poor SERPs results, so time to get up to speed with it! With this in mind, we’re going to look at one of the quickest and simplest methods of improving the performance of your site – GZIP compression.
WordPress GZIP Compression – What is it?
GZIP is the name of a piece of software used for GZIP compression and decompression is, and it’s also the name of the file format that the program uses. It was invented by Mark Adler and Jean-loup Gailly, who made it available for free. They wanted it to replace the compression program that was in use in early Unix systems.
As is the case with WordPress core software, GZIP was intended to be used by GNU, which is free open-source software. It actually lent the “G” from its name to GZIP.
For instance, it can handle audio files like MPEGs and WAVs but ask it to crunch an MP3 file down to size and it may actually do the opposite and make the file bigger.
If you want zip compression to work on your Web server then you need to enable both folder compression and file compression. Web servers that have GZIP enabled will return the content-encoding: GZIP header in their response.
Every modern web browser supports GZIP compression and it will automatically ask for this when making HTTP requests. It’s good to know that all of your users will benefit from GZIP compressions using WordPress GZIP compression once you’ve got it up and running.
Why GZIP Compression Matters
Apart from the implications for search, a website that doesn’t use GZIP compression and loads slowly will harm the experience of your users, which may put them off from buying from you.
Surveys have suggested that around 47% of website users expect a page to load in no more than two seconds. Up to 79% of customers are a lot less likely to purchase from your website if they aren’t happy with the user experience it provides, so if you’re somebody who is running an e-commerce website, this could prove to be very detrimental to your business.
- Google Pagespeed Insights (it’s worth listening when the advice comes straight from the horse’s mouth!)
So what is compression and how does it work? Put simply, it’s a handy way of removing all of the unnecessary stuff in a group of files so that they take up less space but don’t lose any of their original information.
GZIP is great at doing this for WordPress websites and by doing so it can really help to improve your website’s performance, particularly when it comes to page load times.
How Does WordPress GZIP Compression Work?
When users visit your website, their web browsers download these files and use the information they contain to start rendering the page, reassembling it per the code that the files contain. This means that the information is then turned into something readable that the average person can understand, which is exactly what you want!
But browsers are people, so they don’t need all the extra formatting and white space that makes text easier to read for humans. As long as the browser can understand the content of the code it doesn’t matter what it looks like, even if it’s just one long ugly piece of text.
The general idea is that WordPress GZIP compression gets rid of all the formatting that makes it easier for humans to read. This obviously reduces the size of the file while preserving the information.
GZIP Test For Checking if Zip Compression Has Been Enabled in WordPress
If you have the kind of web host who will have already enabled GZIP compression for you during setup, then you’re in good shape, but if you’re not sure then it’s fairly easy to check GZIP compression status using online tools like GiftOfSpeed GZIP Test.
The ways you can check for GZIP compression are usually fairly similar irrespective of which GZIP test tool you pick. You just need to provide the URL for your website, then start the search.
The tool will then either confirm that GZIP compression is enabled on your website and that you have saved ‘X’ amount of space, or it’ll tell you that it’s disabled at the moment.
If you want to find out whether your browser received the content-encoding: GZIP header in the response from the webserver, just do this:
In Chrome, look under Developer Tools > Network, then click on the name of the homepage. Some information will appear, scroll down through this until you find the section marked Response Headers.
How to Enable WordPress GZIP Compression
You actually need to enable WordPress GZIP compression on the server-side rather than the WordPress side. When you buy hosting from popular hosting companies, you’ll find that in their standard hosting packages they’ve already got this enabled. With some other web-hosting providers, you’ll need to do this yourself.
If you discover that WordPress GZIP compression isn’t enabled yet, you can use one of a few different methods to begin. We are going to go through a few ways of enabling GZIP compression in WordPress that should suit you whether you’re a beginner or a highly experienced web developer.
Enable WordPress GZIP Compression under Apache
You can switch on GZIP compression for your WordPress website by making changes to your .htaccess file ( which is part of Apache infrastructure ). A lot of people take this approach, but unfortunately doing it this way means that there is a chance that something might get broken! It’s hardly surprising because messing with a sensitive server file like .htaccess means that one little mistake can have big consequences that crash your website.
To lower your chances of messing up your WordPress website, do the sensible thing and backup your original file before you change anything, not only that but backup your WordPress website too! Once you’re completely sure that you can recover from a catastrophic failure if you need to, it’s time to get things underway.
The .htaccess file is usually hidden on both the remote server as well as your computer, you should be able to find it in your website’s root folder.
The ideal method is to access the file using FTP, and we could also use another admin interface or Plesk.
To enable WordPress GZIP compression in your FTP client, you’ll need to make hidden files visible.
Once you find your .htaccess file, you can make changes, but first it might be better to download it to your own computer and make them there. The file is most likely going to be hidden on your machine so you need to instruct it to show hidden files.
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, using it to overwrite your original .htaccess file. Check your website with a GZIP compression checker tool (or verify the response headers) to check if it worked.
Enable GZIP Compression on NGINX
Although the majority of most shared hosting plans use Apache web servers, you could be using something else, like NGINX.
To enable GZIP compression for NGINX web servers you have to go about it differently. If you’re running on NGINX, you can enable GZIP compression in WordPress by finding your nginx.conf file and adding this code:
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
Contact Your Web Host to Enable GZIP Compression
If you’re not comfortable making changes to your website files, it’ll be easier to ask your web host to enable WordPress GZIP compression for you.
A lot of web hosts, including GoDaddy, Kinsta, and Siteground enable WordPress GZIP compression automatically because it improves performance so much, while others will give you the instructions and let you set up WordPress GZIP compression yourself.
If you don’t have GZIP compression enabled by default and you’re not sure how to change that, then don’t be afraid to talk to your web host. Most of them will usually be perfectly happy to help you.
A Plugin to Enable WordPress GZIP Compression
WordPress GZIP Compression can be set up using a plug-in, but while that may be easier it could also expose you to additional security issues and take up more disk space on your server. But if you do choose to go down this route then here are some plug-ins that can help you enable WordPress GZIP compression.
But Enable GZIP Compression was designed for only one purpose, enabling and disabling GZIP compression for your WordPress site when it’s on an Apache webserver.
WP Rocket is a caching plugin, and in just a few clicks it can help WordPress sites load faster. Once you’ve activated it, WP Rocket adds GZIP compression rules in the .htaccess file using the mod_deflate module.
W3 TOTAL CACHE
W3 Total Cache is among the best WordPress caching plugins, but it isn’t for beginners and it may break your website if you don’t know how to use it correctly. But if you are comfortable then it can be useful for helping you to enable HTTP compression. Just go to the browser cache, and then check the box for HTTP compression.
WP SUPER CACHE
WP Super Cache is another WordPress cache plugin that lets you compress code.
To enable WordPress GZIP compression with WP Super Cache, go to the WordPress dashboard > WP Super Cache > Advanced > and check the box for Compress pages. This will ensure that they’re served to visitors more quickly.
There are lots of ways to improve your WordPress site’s speed and page load times, but GZIP compression is one of the easiest ways to do it.
It’s not difficult to check whether you have WordPress GZIP compression enabled, and it’s well worth doing. Giving this a little of your time will pay you back tenfold in terms of avoiding lost revenue from potential customers who got put off by your slow page load times.
When you’ve finished with implementing WordPress GZIP compression, that isn’t the end of the story. You can still improve your page speed further by getting into things like image optimization plug-ins or using a CDN. There’s lots to learn but thankfully it’s pretty much all available for free.