Smaller file sizes help you to achieve faster loading time on your WordPress Site. The size of your webpage can be reduced by using Gzip compression.
Also, google alerts for sites that do not have compression enabled. In this guide, you will learn how to enable Gzip compression to your WordPress website by modifying the .htaccess file.
- A Domain name (example.com)
- cPanel Credentials
- FTP Client (Cyberduck, Filezilla)
- Text Editor (Notepad, Sublime Text)
How does Gzip Compression Work?
The working of Gzip compression is very simple. It uses an algorithm which organizes repeated strings in a single place only, instead of saving those same strings again and again.
And it manages those strings with their location values while compression and retrieving data back from compressed files. Gzip compression works fine with stylesheets and web pages because all these resource files have many repeated strings. Because of its compression technique, Gzip can reduce the file size by 80-90%.
Login into your cPanel with your username and password.
Click on File Manager under the Files section.
Locate the .htaccess file located in the public_html directory. You can also use the Filezilla client application to locate the .htaccess file.
Right click the .htaccess file and Click on Edit. It will show up the Edit pop up. Click on Edit button.
Add the following line of codes at the end of your .htaccess document
Add the following line of codes if your website is hosted on a Nginx server.
Click on Save Changes to save your changes.
There are WordPress plugins available which can help to enable to Gzip compression to your site. W3 Total Cache is one of the most used popular caching plugins on WordPress. Using this plugin, you can enable Gzip compression.
You can enable Gzip compression with W3 Total cache by going to its settings page. Go to the Browser cache page. Enable the HTTP compression option and click on Save Changes.
Congratulations, You’ve learned how to enable Gzip compression in your WordPress website using the .htaccess file. You can also enable compression using different caching plugins like W3 Total cache or GZip Ninja Speed Compression. Nowadays, Gzip Compressions comes enabled by default with modern web hosting servers.
Check out these top 3 WordPress hosting services: