Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  WordPress FAQ  >  Learn to Enable GZIP Compression in WordPress
Top Scroll

Learn to Enable GZIP Compression in WordPress

 3 min

The very first solution to achieve faster load times of your WordPress CMS is to reduce your page size. Enabling GZIP compression is the simplest method to reduce the size of your website, and improve the time to first render of your web pages. When you enable GZIP compression on your server it helps to significantly reduce the amount of time to download the requested resource. In this tutorial, you will learn to enable GZIP compression on WordPress.
Let’s start.

Steps to Check If GZIP Compression is Enabled

In order to check if the GZIP compression is already enabled on your site, you have to search the Internet and check for ‘GZIP compression online check’. This is one of the easiest ways to check if the GZIP is enabled on your server.

Steps To Enable Gzip Compression For WordPress Websites

You can use several different methods to enable GZIP compression on your WordPress website.

Enable GZIP on Apache

For enabling GZIP compression on Apache web server, you will need to edit your .htaccess file. Add the below lines of code to your .htaccess file. You can find the .htaccess file in the root or the WordPress site.

# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
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/x-javascript
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/javascript
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[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Enable GZIP with WordPress Plugin

You can also use a caching plugin that support GZIP compression. For instance, the WP Rocket will add GZIP compression rules to your .htaccess file and it will automatically use mod_deflate. For enabling this via W3 Total Cache, you will need to go under its performing section and then enable it.

Enable GZIP on NGINX

To enable GZIP on NGINX, you simple have to add the below lines to your nginx.conf configuration file:

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_vary on;
gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/
javascript application/x-javascript;

Surely, you don’t have to enable GZIP compression in WordPress, if you use our managed WordPress hosting service, in which we already include GZIP compression. If there is any issue with this, you can contact our support team via live chat or email.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.