GZIP compression for WordPress

Wazix Wordpress Services

[vc_row][vc_column][vc_column_text font_size=”24″]Are you working on optimizing your WordPress website? Then the term ‘GZIP’ will sound familiar to you.

Activating GZIP for WordPress has a positive effect on the loading time of your website. By compressing files, which you may also know from “zipping” files, they can be delivered to your visitors faster.

GZIP compression can also be used for WordPress files. In this article I will explain what GZIP compression is and how you can activate GZIP for your own website.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

1. What is GZIP compression?

GZIP is a method to compress, reduce file size, for faster network transfers. It allows your web server to send much smaller files to your visitors, which results in your web pages being loaded faster.

GZIP will mostly compress HTML, CSS and JS files which are used to create your WordPress website.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

2. How to activate GZIP compression for WordPress?

You activate compression by changing the configuration of your web server. The most common web servers are highlighted in the list below.

Note: Activating GZIP can cause increased CPU usage on your web server. However, the benefit of compression is much higher than the increased CPU usage. [/vc_column_text][vc_column_text]

2.1 Activating GZIP via your hosting provider

The .htaccess file is a small text file on your web server that controls various aspects of your website. Including redirects, caching and enabling compression. A small incorrect modification in the .htaccess file can cause your website display incorrectly or not display at all.

If you are not familiar with modifying the .htaccess file it is advisable to contact your hosting provider or an expert which can make the changes for you.[/vc_column_text][vc_column_text]

2.2 GZIP compression via .htaccess

To enable GZIP compression via the .htaccess file you must log in to your web server by using FTP. The .htaccess file is located at the root of your web server where WordPress is installed as well.

Make sure that your FTP client shows hidden files if you are unable to locate the .htacess file.

Once you have opened the .htaccess file you can add the following code:

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

Save the file after you added the code to the .htaccesss file and upload it to your server. Refresh your page and test if GZIP compression is enabled.[/vc_column_text][vc_column_text]

2.3 GZIP compression by using a plugin

Do you already have a caching plugin configured? Then enabling GZIP compression is usually possible within this plugin. Have a look at the settings of your caching plugin to activate GZIP compression. Below we will discuss the most used caching plugins and how to enable compression.

WP Rocket
When activating the plugin, WP Rocket automatically adds a line to your .htaccess file. No further configuration for GZIP compression is required.

WP Super Cache
To activate GZIP compression for WP Super Cache, you go to WordPress dashboard > WP Super Cache > Advanced > enable the checkbox Compress pages so they’re served more quickly to visitors.

W3 Total cache
W3 Total cache also offers the option to enable compression. Go to WordPress dashboard > W3 Total cache > Browser cache and check HTTP compression.

PageSpeed Ninja

PageSpeed Ninja focuses entirely on optimizing your WordPress website. Therefore you can easily enable GZIP compression. To do this you go to WordPress dashboard > PageSpeed Ninja > Settings > Advanced and select GZIP compression in the section Enable Compression.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

3. What are the benefits of GZIP?

The easiest way to determine how much your website will benefit from GZIP compression is to do a GZIP compression test.

In general, gzip compression reduces file size by approximately 50% to 70%. This allows your webpages to load much quicker. In addition, you will use less disk space of your web server and you use less bandwidth as well.[/vc_column_text][/vc_column][/vc_row][vc_row el_id=”test-gzip-compression”][vc_column][vc_column_text]

4. Testing of GZIP compression

After configuring and activating GZIP, you might wonder if you configured it correctly and if it benefits the speed of your website. The easiest way to test if you enabled GZIP correctly is to do a GZIP compression check. This tool checks if GZIP is enabled correctly and shows the compression percentage of your website.

Isn’t GZIP configured correctly or do you still experience slow loading times? Do not hesitate to contact us and ask for assitance. We will be glad to have a brief look what might be the issue or provide suggestions of how to further optimize your website.

Our WordPress Lease and WordPress All-in-one package have compression enabled by default.[/vc_column_text][/vc_column][/vc_row]

By Mitch

Mitch Gooijer has chosen to fully focus on his companies Infinius and Wazix, after obtaining his Bachelor of Science. As a Software Engineer he is competent in the development of (mobile) applications and websites. Mitch has over 10 years of Wordpress experience and is specialized in Wordpress development, support and maintenance.