How to enable GZIP compression for your WordPress site
“Slow load time on WordPress site sucks”isn’t? everyone keeps a wish to achieve the good rank of a site but, somehow they face a roadblock. In this article, we will help you to enable GZIP compression for your WordPress website. This trouble arises due to the size of your pages on your website.
- The Unoptimized images are common culprits for the slow site. Size of images should be under 100kb.
- Code density, sometimes Inefficient code exist.
- External Embedded Media.
It’s essential, that you optimize your site for performance at all times.
As a website owner, you probably understand the importance of website speed and page loading time, In fact, loading speed is so important. If web pages quickly available to visitors it will influence your bounce rate, user experience, ranking and much more.
Navigate your site to run at peak efficiency, take a step towards GZIP compression an effective way to make your site load faster, also called HTTP or browser compression.
GZIP compression:
GZIP is a file format, a software application used for file compression and decompression. GZIP compression is enabled server-side and allows for further reduction in the size of your HTML, CSS, and JavaScript files. Before the page is sent to the visitor, it saves bandwidth, therefore, increases the loading speed of the page significantly.
The visitors’ web browser automatically decompress the page compression and decompression, which only take a fraction of a second. Compression is the process of encoding information using fewer bits
- Compress 100kB file to 10KB.
- Reduces Page sizes & Increase page speed.
You can test your speed, with tools like Google page speed insight and GTmetrix. In case you don’t have GZIP enabled, Following warning and error display:
- Enable compression warning in Google PageSpeed Insights.
- Enable GZIP compression warning in GTmetrix
Read More: How to Reduce Server Response Time for WordPress Sites
How to Enable GZIP Compression
![How to enable GZIP compression for your WordPress site](https://techcresendo.com/wp-content/uploads/2020/04/Untitled_design_owdzu3.png)
If you don’t have GZIP compression enabled, don’t get panic. Let’s have a look at a couple of ways you can go about enabling it on your web server. You, need to understand that compression is not handled by WordPress itself but, through a server configuration.
1. Enable Gzip Compression in WordPress via .htaccess
To enable Gzip Compression in WordPress via .htaccess, you need to log into your cPanel and follow the following steps.
- Under file section, select file manager menu.
- Check the checkbox show hidden files and click Go.
- Under public_html folder of your website, find and edit the file called .htaccess.
- Paste the following code into .htaccess file at the end of your existing content.
- GZIP Compression – Copy and Paste the following code in WordPress .htaccess file of your website.
# BEGIN GZIP COMPRESSION <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> # END GZIP COMPRESSION
The instructions and code above will work on Apache. If they are not working there is another way that may work for you. If the above code did not seem to work, remove it from your .htaccess file and try this one instead.
- DEFLATE Compression – Copy and Paste the following code in WordPress .htaccess file of your website.
# BEGIN DEFLATE COMPRESSION <IfModule mod_filter.c> AddOutputFilterByType DEFLATE "application/atom+xml" \ "application/javascript" \ "application/json" \ "application/ld+json" \ "application/manifest+json" \ "application/rdf+xml" \ "application/rss+xml" \ "application/schema+json" \ "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ "font/eot" \ "font/opentype" \ "image/bmp" \ "image/svg+xml" \ "image/vnd.microsoft.icon" \ "image/x-icon" \ "text/cache-manifest" \ "text/css" \ "text/html" \ "text/javascript" \ "text/plain" \ "text/vcard" \ "text/vnd.rim.location.xloc" \ "text/vtt" \ "text/x-component" \ "text/x-cross-domain-policy" \ "text/xml" </IfModule> # END DEFLATE COMPRESSION
2. Enable Gzip Compression with WordPress plugin
Here, is some sort of plugin solution to set up Gzip compression. One of the easiest way using a plugin that supports enabling GZIP.
- “WP HTTP Compression Plugin“, This plugin allows you to output the pages in Gzip compressed format, allows your WordPress blog to output pages compressed in gzip. HTTP compression generally means a 60-80% REDUCTION in the size of your pages (broadband usage) as well as an INCREASE in download speeds of 3x to 4x. Download, install and activate ⇒ https://wordpress.org/plugins/wp-http-compression
- “WP Super Cache“, Another plugin option which generates static HTML files from your dynamic WordPress blog. After an HTML file is generated your web server will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts, You can find an option to Compress pages so they’re served more quickly to visitors. Download, install and activate ⇒ https://wordpress.org/plugins/wp-super-cache/
- “W3 total cache“, the most popular plugin which has a great role in optimization of your WordPress site. It improves search engine result page rankings, especially for mobile-friendly wiebsites and sites that use SSL and up to 80% bandwidth savings via minify and HTTP compression of HTML, CSS, JavaScript and feeds. Download, install and active ⇒ https://wordpress.org/plugins/w3-total-cache/
- “WP Rocket“, It also helps to boost the performance of its site without effort and improve the user experience. Furthermore, support is effective and responsive! but also comes with compression built in. Download, install ⇒ https://wp-rocket.me/
Read More: 5 Best CDN Providers To Speed Up Your Website
3. Enable Gzip Compression on NGINX
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;
It’s Done!
Read More: The Top Best Cache Plugins For WordPress
Good Luck! 🙂 If you liked this article, then please subscribe to our YouTube Channel. You can also search for the latest tech news and follow us on Twitter, Facebook, and LinkedIn.