How To Enable GZIP Compression In WordPress
Learn How can you fix the Warning of Enable GZIP Compression In WordPress. You may get this warning on gtmetrix , pindom tool, or google pagespeed Tool. Gzip Compression is very helpful in increasing website speed Before I start explaining How can fix the error lets me have some basic information about gzip compression
What is GZIP Compression?
Gzip comes from the word G+ZIP. G means GNU and Zip means Compressing. Here Gnu is a company name. Gzip is a format used for compression and decompression. Decreasing the page size is quite difficult for any website. But you can decrease the website by compressing it using gzip.
How Does Gzip Compression Work and why we should use it?
I will explain Gzip compression works in simple words. Let’s assume you have a ball of 20kg if you will throw it directly toward me there may be a chance that I may break my hand. But if I compressed it inside a box by using gzip compression the weight of the ball will be around 13 kg and it’s quite easy for me to catch the ball. Similarly when your page size is too big when your server sends big data size data content. Then the loading will get affected and if you will compressed it the loading gets faster. Once you enable gzip compression then the HTML, CSS, javascript, and PHP size will be reduced from the server-side. Gzip compression is not valid for images, videos. You need to separate optimization for images.
You may also be interested in WordPress Speed Optimization, Caching Plugins, and Free Email Marketing Services
How to Enable Gzip Compression?
You can enable compression via 2 Methods. In both cases, you will get almost the same result.
1. Plugin Method
#1 Enable GZIP compression plugin
You need to install and activate the plugin. Once you activate the plugin that code will automatically get added to your .htacess file.
#2 W3 Total Cache Plugin
You need to follow the path for enabling the compression in W3 Total Cache – Browser cache >>>> enable HTTP (GZIP compression ) and check that option.
#3 WP Super Cache plugin
You need to follow the path for enabling the compression in WP Super Cache – Advance >>>> Miscellaneous >>>>> compress pages so that ….. check that option.
#4 WP Fastest Cache
For the wp fastest cache user you just need to click on the settings tab. Under that, you will gzip (Reduce the size of the file sent from the server ) Just check that option, and you are done.
Using Wp-rocket you can achieve all the functions easily like a magnification of HTML, CSS, and js files. Apart from that, it has many functions to make it possible for your website to get 100/100 in website loading tools.
#6 Comet Cache – In the case of Comet Cache plugins you need to move under Apache optimization. Inside that select “Yes enable gzip Compression ( Recommended ) ” and now you are done.
2. Without Plugin Method
How to Fix “Enable Gzip compression” warning using .htaccess (Apache server)
You need to paste the below mention code to your .htacess file this will enable gzip compression on your WordPress file. The below code is valid for all kinds of plugins like comet cache , wp-rocket and fastest cache
# 1.BEGIN Gzip Gomahamaya
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
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/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
</IfModule>
# END Gzip Gomahamaya
Finally, your code in .htacess should look like this
Enable GZIP on NGINX
You need to add it to your NGINX server config 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;
FAQ
Why gzip compression is not working On my website?
- You need to understand one simple concept that whatever the content you are not hosting inside your server, you can’t compress it.
- If still, you think the code is not working then you need to enable mod_deflate on my server. It’s better to contact your hosting providers.
Sir Can I do it with Yoast SEO plugin. If yes then please share the information.
Hello Satendra,
You can’t enable GZIP Compression using Yoast plugin because that is SEO Plugins
Regards,
Rahul