Gzip compression reduces the size of HTML files, JavaScripts,CSS stylesheets and XML files. In general, enabling (using) Gzip compression with the WordPress plug-in can reduce site size by 60 to 80 percent.

enables Gzip compression through .htaccess in WordPress to reduce server response time and the amount of data the server sends to Web browsers. Of course, compressing the page size helps reduce the response and data transferred. The best way to enable compression is to use mod_gzip or mod_deflate in the .htaccess file of the WordPress site server. You just need to enable Gzip compression by adding a simple code to the .htaccess file in your website’s WordPress installation directory.

if you don’t want to enable compression through .htaccess files, we can also use some plug-ins, such as the W3 Total Cache,WP Super Cache plug-in, which supports enabling Gzip compression in WordPress.

Article reading navigation


what is Gzip compression?

Gzip is a file compressor Used to compress and decompress files. It provides the best version of compressed text files such as CSS stylesheets, HTML, and JavaScript files. When enabled on a Web site, Gzip compresses the file before transferring the file from the server. Therefore, it improves page speed, loading time, and saves the amount of data requested by users. If you want to learn more about Gzip compression, check out these links [1, 2]. The concept of


Gzip compression how?

Gzip compression works is very simple. It uses an algorithm that organizes duplicate strings in only one place, rather than saving the same strings over and over again. And it manages strings with location values when compressing and retrieving data from compressed files. Gzip compression works for stylesheets and web pages because these resource files have many duplicate strings. Because of its compression technology, Gzip can reduce file size by 70-90%.

Let’s take a look at the following example to understand Gzip compression.

assumes that your HTML file contains something like this. The compressed version of

  

Enable Gzip Compression in WordPress

is then shown in the following example.

Hkg6dkGhJkjsdHkgHjL

, however, if the duplicate string in your HTML file is as follows…

Enable Gzip Compression in WordPress

Enable Gzip Compression in WordPress via .htaccess

then, Gzip compression compresses the repeating string into a piece of code, and then compresses the non-repeating string, resulting in something like this. DEFLATE Compression and Gzip Compression

Hkg6dkGhJkjsdHkgHjL/GjDVjs


for

WordPress you may have read about Gzip compression and DEFLATE compression online. If you haven’t already, let’s take a brief look at it. Gzip and DEFLATE compression algorithms are different and are used on different servers. Gzip compression is used for Apache and Nginx servers, while DEFLATE is used only for Apache servers. Before


starts,

first, you should check to see if Gzip compression is enabled on the WordPress website. Google Gzip compression testing tools or varvy gzip testing tools provide such services. If compression has been applied to your site. You can then check that compression is enabled correctly. Or is there more compressed space? The technology of those who can achieve higher compression is better.

you also need to find out which Web server software (Apache or Nginx) your Web host is using. Because the Gzip compression method enabled is different for the two servers.


enablesGzip compressionfor WordPress through

Web server configuration to enable Gzip compression through .htaccess of the WordPress website, you just need to open the .htaccess file in the root directory of the WordPress installation, copy and paste the following code, and save the changes. Then check the compression testing tool again, and after testing, you will find that Gzip compression has reduced the page size of your site and will increase the page loading speed.


Compression

Gzip Compression on the Apache server-add the following code to the .htaccess file under the WordPress root of your website.

# BEGIN GZIP COMPRESSION

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.*

# END GZIP COMPRESSION

DEFLATE Compression-copy and paste the following code into the .htaccess file in the WordPress root directory of your website.

# BEGIN DEFLATE COMPRESSION

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"

# END DEFLATE COMPRESSION


Compression

Gzip Compression on Nginx Server-paste the following code into the configuration file on the Nginx server of the hosted Web site (typically located at / usr/local/nginx/conf/nginx.conf). The compressed result of the

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;


application,

. Com, is hosted on the Nginx server, so the site uses Gzip compression. After enabling Gzip, the size of the web page has been reduced by 72%. At first, my web page size was 62299 bytes (no compression). After compression, the page size was only 17671 bytes. Of course, there is a lot of compressed space, but we use 2X high-definition pictures to ensure that the pictures on the site fit with the 4K monitor.
WordPress Website Using Gzip Compression to Improve Site Load Speed Tutorial Illustration
WordPress enables Gzip compression technology, Test .com

recommends reading: website Speed performance testing tutorial


uses W3 Total Cache cache plug-in to achieve Gzip compression

W3 Total Cache is one of the most commonly used cache plug-ins on the WordPress platform. If you use this plug-in, you can enable Gzip compression through this plug-in. Follow these steps to enable Gzip compression-W3 total cache using the WordPress plug-in-W3 Total Cache

  • Go to the W3 Total Cache cache plug-in settings page
  • enters the Browser Cache tab
  • check the Enable HTTP Compression option
    Finally,
  • , don’t forget to save the settings.

WordPress Website Using Gzip Compression to Improve Site Load Speed Tutorial Illustration1

uses the WordPress cache plug-in-W3 Total Cache enables Gzip compression


uses theWP Super Cachecache plug-in to implement Gzip compression

WP Super Cache is another mainstream cache plug-in. Enabling Gzip compression is also very simple, follow these steps to enable Gzip compression using the WP Super Cache plug-in.

  • enters the WP Super Cache plug-in settings interface
  • Click the Advanced tab
  • check the first option in Miscellaneous (other settings)
  • finally save settings can

WordPress Website Using Gzip Compression to Improve Site Load Speed Tutorial Illustration2

use WordPress cache plug-in-WP Super Cache enable Gzip compression

another WordPress site optimization plug-in-Autoptimize is also very popular, interested webmasters may wish to try the following!


is written last

Gzip compression is one of the most commonly used file compression techniques. In addition, it is also one of the PageSpeed optimization recommendations recommended by the old webmaster. Today, many server providers generally turn on Gzip compression by default. However, if you are using a VPS server or a stand-alone server (some virtual hosts) that may not be enabled by default, you can enable Gzip compression according to the above tutorial. If you have any questions in this respect, please feel free to leave a message and discuss with us. Or, tell us what percentage of compression you achieved by enabling Gzip compression?

in addition, Gzip compression is only a small part of website optimization, if you want to optimize the site comprehensively, you may also need to compress pictures, set browser cache, CDN acceleration, JavaScript and CSS optimization, efficient caching strategy.

Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.