How to Enable GZip Compression

GZip Compression is a compression technique that uses the Gzip algorithm to reduce file size. GZip Compression is usually used to compress HTML, CSS, JavaScript and other text files and this is How to Enable GZip Compression.

GZip Compression works by optimizing and making files smaller by removing redundancy from the data contained in the files. This can make files easier to transfer and open quickly.

GZip Compression is widely used on the internet to reduce the size of files transferred over the network, thus speeding up the loading time of a web page.

By enabling GZip Compression, you can reduce the size of files transferred over the network by up to 70%, thus speeding up the loading time of your wordpress website pages. This will provide a better experience for your website visitors.

How to Enable GZip Compression

To Enable GZip Compression, you need to access the files .htaccesson your web server. If you do not have access to this file, you will need to contact your system or hosting administrator for assistance.

If you can already access the files .htaccess, follow these steps for How to Enable GZip Compression:

  1. Open the file .htaccessin your text editor.
  2. Add the following lines of code at the top of the file .htaccess:
<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>

Gzipped with mod_deflate.

# BEGIN DEFLATE COMPRESSION
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# END DEFLATE COMPRESSION
  1. Add the two codes above.
  2. Save changes to the file.htaccess
  3. Upload the .htaccessupdated file to your web server.

By adding the above lines of code to your .htaccess, you have successfully enabled Gzip compression on your web server. This will help reduce the size of files transferred over the network, thereby speeding up the loading time of your WordPress website pages .

How to Enable GZip Compression on the Ngix Server

How to Enable GZip Compression on the NGINX web server, you need to access the files nginx.confon your web server. If you do not have access to this file, you will need to contact your system or hosting administrator for assistance.

If you can already access the files nginx.conf, follow these steps for How to Enable GZip Compression:

  1. Open the file nginx.confin your text editor.
  2. Find the httpblock section and add the following lines of code in it:
gzip on;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  1. Save changes to the filenginx.conf
  2. Restart your NGINX web server to activate the changes you’ve made.

By adding the above lines of code to your nginx.conf, you have successfully enabled Gzip compression on your NGINX web server. This will help reduce the size of files transferred over the network, thereby speeding up the loading time of your web pages.

Activating the WordPress GZip Compression Plugin

If you are using a CMS like WordPress to create your website, you can activate it with How to Enable GZip Compression using a plugin. One of the plugins that you can use is W3 Total Cache.

Here are the steps to enable Gzip compression using the W3 Total Cache plugin:

  1. Install and activate the W3 Total Cache plugin on your WordPress.
  2. Go to the Settings menu > W3 Total Cache in your WordPress.
  3. On the Page Cache tab, enable the Enable option.
  4. On the Browser Cache tab, enable the Enable option and check the Don’t set cookies option.
  5. Scroll down the page until you find the Content Delivery Network (CDN) section. Activate the Enable CDN option and select the CDN provider you are using.
  6. Scroll down the page until you find the General Settings section. Enable the Enable HTTP (gzip) compression option.
  7. Click the Save all settings button to save changes.

After you have followed the steps above, Gzip compression should be enabled on your website. This will help reduce the size of files transferred over the network, thereby speeding up the loading time of your web pages.

Performing the GZip Compression Test

To test whether Gzip compression is enabled on your website, you can use an online tool such as GTmetrix. Here are the steps for performing a gzip test using GTmetrix:

  1. Go to the GTmetrix page at https://gtmetrix.com/
  2. Enter the URL of the website you want to test in the URL field on the GTmetrix page.
  3. Click the Analyze button to start testing.
  4. Once the testing process is complete, GTmetrix will display the test results, including information about whether Gzip compression was enabled on the website you are testing.

If Gzip compression has been enabled, you will see a Compressed column in the Waterfall tab of the GTmetrix test results. The Compressed column will display information about the size of the Gzip compressed file.

If Gzip compression isn’t already enabled, you’ll see an Uncompressed column in the Waterfall tab of the GTmetrix test results. The Uncompressed column will display information about the size of the file before it is compressed with Gzip.

Apart from using GTmetrix, you can also use other online tools, such as PageSpeed ​​Insights, WebPageTest, and others to perform a gzip test of your website.

If you don’t want to be complicated, you can use the Gzip Checker tool https://technumero.com/check-gzip-compression/

Leave a Comment