Gzip Compression WordPress Guide: How to Enable It (5 Methods)
WordPress Gzip compression is a way to speed up your WordPress site by compressing the files that your server sends to visitors’ browsers. With a smaller file size, visitors are able to load your website more quickly, which means better user experience and all the other benefits of a quick-loading WordPress site. However, Gzip compression is not enabled by default for your WordPress site, so you’ll typically need to perform some manual actions if you want to enable WordPress Gzip compression.
Enabling Gzip compression takes very little time, and once you’ve enabled it, there’s no ongoing maintenance – it will just keep working in the background to speed up your website.
Now, let’s get into some different methods that you can use to enable Gzip compression on WordPress.
How to Enable Gzip Compression on WordPress (5 Methods)
To enable Gzip compression, you can add some code to your site’s .htaccess file or use one of the many plugins that enable this functionality.
1. Add Code to Your .htaccess File (Apache Web Server)
If your host uses the Apache web server, which most WordPress hosts do (especially those on the budget end of the spectrum), you can enable Gzip compression by adding some lines to your site’s .htaccess file.
To edit this file, you’ll need to connect to your WordPress site via FTP. If you’re not sure how to do that, you can follow our WordPress FTP guide.
Once you’re connected to your site, find and edit your .htaccess file. However, before making any changes to this file, I would highly recommend downloading a backup copy of the original file to your computer. That way, you always have a working copy if something goes wrong.
Once you have a backup copy of your .htaccess file, add the following lines of code to the bottom of the .htaccess file:
# Enable Gzip compression
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 in 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
2. Use the Enable Gzip Compression Plugin
If you don’t want to mess around with your site’s .htaccess file, there are also several plugin methods that you can use to enable Gzip compression on WordPress.
The first is the aptly named Enable Gzip Compression plugin, which is available for free at WordPress.org.
Once you install and activate the plugin, go to Settings → Gzip Compression and click the Enable Gzip compression button:
One of those techniques is Gzip compression, which WP Rocket automatically enables as soon as you activate the plugin. There’s nothing to configure – just activate the WP Rocket plugin and your site will start benefiting from Gzip compression.
4. Use the SG Optimizer Plugin (If Hosting at SiteGround)
Here at WPLift, we recommend SiteGround as one of the best WordPress hosts, and it’s also the actual WordPress host that we use to run WPLift.
As such, we had to give a special section to SiteGround because SiteGround makes it super easy to enable Gzip compression on your WordPress site via its free SG Optimizer plugin.
Once you’ve activated the plugin, go to the new SG Optimizer tab in your WordPress dashboard. Then, head to the Environment Optimization tab and use the toggle to enable Gzip compression:
Once you install and activate the free plugin from WordPress.org, head to the new WP Fastest Cache area in your WordPress dashboard. Then, check the box to enable Gzip and save your changes:
All you do is enter your URL and hit Test. Then, the tool will spit back the results: