To achieve faster load times on your WordPress site, it is important to reduce the size of your pages. This represents the difference between a loading platform within 1 second and a platform that feels like it is crawling. Enabling GZIP compression on your WordPress website can help to reduce the size of your webpage, which can significantly reduce the download time of the resource, reduce data usage for the customer, and improve the time it takes to deliver your pages first.
Nowadays, All modern browsers support these and automatically negotiate the GZIP summary for all HTTP requests.Let us check and enable the GZIP Summary of our web server.
First thing we have to know is What is GZIP Compression? Here we are using GZIP file format Software Application for compressing and decompressing the files. The GZIP abbreviation is enabled as a server page and allows you to further reduce the size of your HTML, stylesheets and javascript files. It does not work on images because these are already compressed in a different way. Some have seen reductions of up to 70{c11b4ab6dc2c9e87c276140fc663c87923e2a03a3ad9c27368d6191e0f8759f5} due to contraction. This is one of the easiest updates you can make when it comes to WordPress.
Summary is the process of encrypting information using fewer bits.When a web browser visits a website, the web server checks whether GZIP is enabled by looking for the response title “Content-Encryption – GZIP”. If the title is found, it helps to compress the small files. Otherwise, provides uncompressed files. If GZIP is not enabled, you may find warnings and errors in speed testing tools such as Google PageSpeed Intelligence and GTMetrix like
GZIP Alert on Google PageSpeed Intelligence
Now you can see, Google says that GZIP is shrinking resources with it or deflating which can reduce the number of bytes that are sent over the network.
GZIP Alert on GTmetrix
Here you see how GTmetrix recommends for the enabling gzip compression to reducing its transfer volume of static resources
Let us check whether the GZIP compression is enabled
GZIP runs default in all kinsta servers; it is very common nowadays. Don’t worry about the support of GZIP browser, it has been supported by many over 17 years.
I have listed the list of browsers which can handle the HTTP response header
- Internet Explorer 5.5+
- Opera 5+
- Firefox 0.9.5+
- Chrome
- Safari
If you are running on a different WordPress host, you should always check to make sure it is enabled, because the server administrators often overlook this optimization. There are two quick ways to check GZIP compression
1. To Check the GZIP compression tool
The first and quickest way to check if your site has GZIP compression enabled is to go to the free check GZIP compression tool. Enter your website and click Search. This will compress the page with GZIP and provide the saved amount or it will give you an error stating that GZIP is not enabled.
Remember that GZIP also applies to your fixed assets. This means that if you are serving assets from a CDN, you must ensure that the GZIP compression is enabled on them as well. All modern CDN providers which support the GZIP compression such as Kinsta CDN, CloudFlare, KeyCDN and CloudFront. You can also easily test this by running one of your CSS or JavaScript files on your CDN with the tool.
2. GZIP content-encrypted HTTP response title
Next way to verify that the “Content-Encryption: GZIP” HTTP response title is active on your site. The browser searches for this when sending a request to the server. You can open Chrome Devtools and see your first response title under the Network section.
Now you can also click the “View Larger Requests” option, which will show the original and compressed size of the page. When you see below the original page it shows 51.6 KB before compression and the GZIP compressed version file is 17.7 KB.
Enable GZIP Compression
If you do not have GZIP compression enabled, there are two ways to enable it on your web server.
Enable GZIP with the WordPress Plugin
First and foremost is using the caching plugin that supports running GZIP. For example, WP Rocket automatically adds GZIP compression rules to your .htaccess file using the mod_deflate module. The W3 Total Cache has a way of running this for you under its performance category. Although these are plug-ins, it relies on permissions to transfer files to your web server. If your caching plugin is not allowed, you should ask your host or use the snippet of code below.
Enable GZIP in Apache
Second way to enable your GZIP compression is by editing your .htaccess file. Most shared hosts use Apache, you can add the code below to your .htaccess file. You can view your .htaccess file via FTP at the root of your WordPress site.
Important: Ensure that mod_filter is mounted on your server, otherwise the AddOutputFilterByType command will not work and may cause 500 errors. We recommend checking your error logs if you have any problems with the code below.
<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>
Be sure to add this below the current contents of your .htaccess file. The following is an example:
Enable GZIP on NGINX
If you are running NGINX, add the following to your nginx.conf file.
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
Enable GZIP on IIS
There are two different types of contractions if you are running on IIS, static and dynamic. Recommend that you look for a Microsoft guide for enabling your compression.