A fast loading website is good for both your audience and your Google search results. That’s right, Google cares about your site speed, not just your content. And they will reward you with better search rankings because faster sites require fewer Google server resources to scan your site. One of the easiest ways to speed up your website is to enable GZIP compression. This is easily done and only requires adding a few lines of code to your server’s htaccess file.
- A WordPress or Apache hosted website
- cPanel or FTP access to your site files
- Basic coding skills
- 5 minutes of free time
Run A GZIP Compression Test
Before you even start this process, it’s a good idea to first run a GZIP compression check. You might already have GZIP enabled on your website and not realize it. Sometimes hosting providers will make GZIP compression a standard part of your site install. Here are a few services that will test if you have GZIP already enabled on your server. Just input your website URL and wait for the results.
GZIP Compression WordPress Plugins
GZIP compression can easily be enabled by just adding a few lines of code to your htaccess file. And there are several advantages of doing it that way. If you are comfortable editing your htaccess file, then skip to the next section below.
But not everyone is comfortable with messing with code. The good news is, there are several WordPress plugins that can help you enable GZIP compression.
- WP Super Cache: Settings > Miscellaneous > Compress Pages
- W3 Total Cache: Performance > Browser Cache > HTTP compression
- WP Rocket: An awesome, but premium plugin that also includes Cloudflare CDN. Compression is auto-enabled.
Advantages Of Adding Gzip Compression Code Directly To Your .htaccess File
Even if you are already using a caching plugin like WP Super Cache or WP Rocket, there are a few advantages of adding GZIP compression directly to your htaccess file.
- Reducing Plugin Conflicts: WordPress plugins sometimes conflict with each other and have to be disabled during troubleshooting. It would be a shame to disable GZIP compression, even temporarily, while working out your plugin issues.
- Increasing Website Speed: Although small, there’s still a speed improvement by calling the GZIP compression at the server level from the htaccess file instead of via a plugin.
- Reduce Opportunity For Errors: Another issue with using a plugin to control GZIP compression is an increase in potential conflicts. Caching plugins usually come with a lot of extra features that you may not need. If you only need a compression solution, then a plugin may just create additional data overhead.
How To Find Your .htaccess File
Before you can edit your htaccess file, you have to find it first. Your htaccess file is on the root level of your web server and can be accessed using several different methods including FTP or cPanel. Talk to your hosting provider about the best way to gain access to your htaccess file.
Another thing to note is that the file might be invisible. Files that have a “.” in front of them, like a “.htaccess” file are invisible. Depending on how you are accessing your web server, you might have to enable an option that allows you to see hidden files.
How To Edit Your .htaccess File
Now that you’ve located your htaccess file, the next step is to edit it. You can either:
- Edit Option #1: Edit the file directly from the server or,
- Edit Option #2: Download it to your hard drive, edit and then upload and overwrite the old file
There are pros and cons to each option.
Option #1: To directly edit the htaccess file, try right-clicking on the file or look for another option that says edit.
Option #2: There’s an advantage of downloading a copy of your htaccess file to your computer. It creates a backup. That way if something goes wrong, you don’t have to try to recreate your htaccess file from scratch.
However, since your htaccess file starts with a “.”, the file might be invisible after you download it to your computer. Nothing is easy, right? So you’ll need to find that invisible file first before you can edit it.
On Mac, you can do a custom file search for invisible files from a Finder window. Just click on the “+” button and select “Visible or Invisible” under the File Visibility dropdown menu.
On a PC, check your Folder and Search Options. Make sure “Show hidden files, folders, and drives” is enabled under the View window.
Add The GZIP Compression Code To Your htaccess File
Now that you have your htacess file open, just copy and paste this code into it. Don’t overwrite any other piece of code. Just add this code to either the top or bottom of the file.
Alternate GZIP Compression Code
If you encounter any issues with the GZIP compression htaccess code above, then try this alternate code.
GZIP Compression Check
After you have installed the code in your htaccess file, the next step is to conduct a GZIP compression test. There are several great services that will test your site’s GZIP compression status. Just input your URL and wait for them to run a GZIP compression check on your website.
GZIP Compression htaccess Tutorial
That’s it! Hopefully, your final GZIP compression test was successful. Congratulations on having a faster website. What worked and didn’t work for you? Please tell us in the comments so we can improve this GZIP compression htaccess article in the future. Thanks for reading!
Leave a Reply