In this post, we'll explain what Gzip compression is and why it matters. Then we'll show you two ways to implement it.
Keeping your website up to date is important. Give a huge boost to your user experience and improve the professionalism and reliability of your site
Gzip compression is a popular method that you can use to speed up your site. Although the term itself may seem technical, the basic concept isn't too complicated.
Enabling Gzip compression on your WordPress site is surprisingly easy.
An introduction to Gzip compression
As your site expands, many of its files grow as well. This is a natural result of adding more content, plugins, and themes, as well as custom code to your site. All this new data needs to be stored somewhere.
The disadvantage of larger files is that they often take longer to load when your pages are accessed. This means that your visitors will have to wait longer to see your content - which is never a good thing. To resolve this issue, you need to find a way to shrink your site's files without losing important information.
That's exactly what Gzip compression does. Reduce the size of your files by "compressing" them, eliminating unnecessary characters, and reorganizing your data more efficiently. If you've ever "closed" a file to make it smaller, this is a similar concept. Gzip compression can reduce the total size of your pages by up to 70% and nothing crucial is lost in the process.
How to enable Gzip compression on your WordPress site
There are a lot of ways to speed up your WordPress site. For example, choosing an optimized hosting plan is the best solution. However, Gzip compression can help you further improve your page speed, so it's worth implementing.
Below, we'll show you two ways to get started with Gzip compression. The first thing you want to do is make sure you have a recent backup of your site as a backup. Then you can read both methods and choose the one you prefer.
1. Use a plugin
You may be struggling to find a quality plugin designed exclusively to implement Gzip compression. Many speed optimization plugins include an option for Gzip compression as part of the feature set. For a perfect example, see WP Super Cache :
This plugin is primarily a caching solution, which is another smart way to speed up your WordPress site. However, it also allows you to compress your files. After installing and activating the plugin, you will need to navigate to Settings > WP Super Cache and go to the Advanced tab:
Find the option labeled Compress pages so that they run faster to visitors and check the box next to it. Then click the Update Status button to save the changes. That's all you need to do - the plugin will now implement automatic Gzip compression!
2. Edit your .htaccess
While the above technique is the easiest way to enable Gzip compression on your WordPress site, some users will be more interested in an alternative method. For example, if you try to limit the number of plugins you install on your site, you may prefer to manually implement Gzip compression.
To do this, you will need to use the Secure File Transfer Protocol (SFTP). This allows you to directly access (and make changes to) your site's files. If you haven't used SFTP before, you'll want to first install a suitable client, such as FileZilla (and hone your SFTP skills). You will then need to establish a connection to your site using your hosting credentials.
Once you've set up FileZilla, it should look something like this:
In the top-right quadrant, find the folder named after the domain of your website and select it. Then, in the lower right dial, look for the file called .htaccess. This is one of the basic files on your site, so you should always be very careful when making changes to it:
Right-click the .htaccess file and select Download to save it to your computer. Then open the file in any text editor (such as Notepad) and paste the following code:
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
Don't forget to save the changes to the file. After that, you can reload it on your site by copying it and pasting it back into the root folder of your website (or simply dragging it there from your computer). With this, you have manually enabled Gzip compression on your WordPress site!
There are plenty of ways to make sure your WordPress site is running fast and efficiently. For example, you'll want to choose an optimized hosting plan. After that, there are a lot of smaller changes you can make to maximize your site's performance, such as using Gzip compression to reduce file sizes.