How to enable GZIP compression (Apache mod_deflate) in cPanel Sites
Compressing web content will help you to speed up the page load times, save bandwidth, and improve the user experience.
The compression will reduce the size of the file before the web server sends them to the internet browser. The process of compressing and decompressing will take less time as compared to sending large files over the internet. Once a browser will receive the compressed web content , it will decompress the web content before displaying the web pages. This process will allow you to provide faster load times and a better user experience.
- The compression depends on the Apache mod_deflate module. So, you will want to make sure that mod_deflate is enabled on your server. If you have root access, you can check it from command line using following command.
root@testserver[~]# httpd -M | grep 'deflate' deflate_module (shared)
- If mod_deflate is not enabled on your server, you can install mod_deflate via EasyApache 4 interface.
- Go to WHM
- Click on EasyApache 4 under Software
- Click on “Customize” button of your profile
- Click on “Apache modules” and find mod_deflate and enable
- Click on “Review”
- Click on “Provision”
- You can follow below steps to enable gzip compression in cPanel.
- Login to cPanel
- Click on Optimize Website under Software. This will allow you to compress your web contents using different options.
- Select the option from the list as per your requirements and click on “Update Settings” to save. The available options are as follows :-
- Disabled: This is the default option and it will disable the compression - Compress All content: This option will compress the entire web content on your website. - Compress the Specified Mime types: This option will allow to specify the type of files that you want to compress.
MIME type syntax is in the format type/subtype. The typical MIME type’s syntax includes;
- You can also enable the Gzip Compression service in the .htaccess file of your site.
You can add respective code to the .htaccess file in the format and save the file.
AddOutputFilterByType "MIME type"
For example, to compress MIME type files image/jpeg and add the line
AddOutputFilterByType DEFLATE image/jpeg
Note :- You can use below codes to compresses application, image, and text, audio and video files. You can change the codes to meet your requirements.
You can test if the gzip compression is working on your site at https://www.whatsmyip.org/http-compression-test/
1,300 total views, 12 views today