Serving compressed files improve the page loading speed of your WordPress site. If compression is not enabled this will be showing with highest priority issues when checked with Google PageSpeed Insights tool. In this article we will explain how to enable compression to speedup your WordPress site.
Check Site with Google PageSpeed Insights Tool
There are many tools to check whether the site URL is served after compression or not. Below is how Google PageSpeed Insights tool will show the error if compression is not enabled on your site.
Since this is high priority issue the page speed score is very low as 36 on desktops.
How to Enable Compression for on Your WordPress Site?
There are two ways you can enable compression on your WordPress site.
- Through cPanel hosting account
- Using .htaccess file
We will explain both the methods in detail.
Enable GZIP Compression Using cPanel
Most of the popular shared hosting companies like Bluehost, SiteGround, etc. use cPanel to host your account. If you have cPanel access for your WordPress installation then you can easily enable GZIP compression without modifying .htaccess file.
Login to your cPanel account and look for the option “Optimize Website”. On SiteGround cPanel this option is grouped under “Advanced” category as below:
Open “Optimize Website” option and choose “Compress All Content” button (by default this will be disabled). This will enable compression on your WordPress site henceforth all content will be compressed before served to users.
Enable Compression Using .htaccess File
Though cPanel has the option to enable compression some hosts may not allow you to enable this option or you may not have access to the hosting account. In such cases, GZIP compression can be enabled by adding the following code in your .htaccess file.
#BEGIN GZIP Compression
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
# END GZIP Compression
Note the followings when editing .htaccess file on your WordPress site:
- The .htaccess file can be modified using plugins or with FTP access.
- The .htaccess file will be located in the root WordPress installation directory that is “/public_html”. If you have installed WordPress on subdirectory then look for the file under that directory.
- The .htaccess file in general is hidden, you may need to enable viewing the hidden files on your Mac or PC.
Checking Back in Google PageSpeed Insights Tool
Now that you have enabled compression on your WordPress site, it is time to check back with Google PageSpeed Insights tool. Before doing that ensure to flush all the caches from the caching plugin and server level. Now that you can see the “Enable Compression” is shown under “Passed Rules” indicating your page is enabled with GZIP compression. This will also improve the page speed score considerably.
Check Compression with Third-Party Tools
Though Google PageSpeed Insights tool is popular, it will not explicitly show GZIP compression problems. There are many third-party tools also offer functions to check the GZIP compression of a webpage. You can use on of these free GZIP Compression Checker tools by entering your site URL and check how much bytes is saved using compression on your site.