How To Enable Gzip Compression in WordPress?
Gzip Compression in WordPress : Gzip is one of the components of the server that allows faster loading of the websites in a compressed form. In WordPress CMS one can enable the Gzip to get their site speed in minimum loading time. In this post we are going to understand the various aspects of Gzip inside WordPress.
Understanding GZIP and How it works?
Once you write website URL name on your browser and put enter then website opens in the front end. But in the back end there are calls sent to server for every html files, CSS files, JS files, images and more. Each file is called separately and takes it time. Now this Gzip utility allows the compressed form of all files in one file. Now after you open or click on the sites url then only file is downloaded rather than lets say 40 smaller files. Now the browser allows swift decompression of this file into front end of the website. Users sees the page with all files. The whole works automatically and reduced the overall loading time by 70% approx allowing sites to appear faster.
WordPress GZIP : Gzip utility works smoothly with WordPress to allow sites to load faster and user sees the web page instantly without any major delays. All HTML, CSS and JS files are reduced to fifty to Seventy (50%-70%).
Benefits Of Using GZIP Compression in WordPress
- Faster Loading Time
- Reduces website size upto 70%
- Low Bandwidth Usage
- Minimum resources needed
- Better User Experience
How To Test GZIP Compression Status Of Your Site in WordPress?
There are several websites and tools which allows quick testing of this compression test from their server. You can easily put your site URL and get your Gzip status checked online. Here are few of these sites
How To Enable GZIP Compression in WordPress?
First of all you need to have access to their admin to enable Gzip Compression WordPress or Server Control of htaccess file where the code is written. There are mainly two ways by which you can allow the Gzip to reduce your browser files request. Here in this post we are going to study the with elaborate examples.
- By using htaccess
- By using plugins
Method 1 : Enable GZIP Compression in WordPress By HTACCESS
Htaccess is a hidden file and located at your public HTML folder in the Cpanel or the Hosted Server mail folder. Sometimes you need to allow hidden files to be seen for accessing this file. Than you can add the following code to get your apache server to run Gzip for your websites respectively.
<ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </ifModule>
and the Longer version
<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>
Method 2: Enable GZIP Compression in WordPress By Plugins
There are many plugins in WordPress Plugins directory that allows Gzip compression from the admin area only. They also add the code to the htaccess file only. There are around 20+ plugins that allow swift change to your site with enable and disable Gzip from admin area. But here are the top five plugins
- W3 Total Cache
- WP Performance Score Booster
- Check and Enable GZIP compression
- WordPress Gzip Compression
- PageSpeed Ninja
Enable GZIP Compression in WordPress By W3 Total Cache
Nowadays W3 Total Cache is a Very popular WordPress plugin with many features for WordPress speed optimization. And if you are using this plugin you can enable Gzip compression using their settings only. Follow the given below steps to enable Gzip compression from WordPress Plugin by W3 Total Cache
- Click on the plugin button and then click on add new plugin
- Search for W3 Total Cache from Search Box.
- Then Install and Activate W3 Total Cache Plugin.
- In the browser Cache Section Enable HTTP Compression box is there you need to tick the box and reset the cache to start compression process.
WordPress gzip compression not working
There are many circumstances when the Gzip Compression doesn’t work and site loads normally without being compressed.
- Server issues : Every hosting and server uses different combinations for their files. For Gzip functionality to work you need to have these specific services enabled from the server first. Apache Server requires following modules to be installed and loaded to get this Gzip working. (mod_setenvif, filter_module, mod_headers, mod_deflate, mod_gzip)
- Conflicts within plugin or files : There might be two or more files using the same code which might cause conflict for any of them to work together. You might need to check these plugins and disable them for reconfiguring them precisely for GZip
Also Must read