How to enable GZIP compression (Apache mod_deflate) in cPanel Sites

If you found this post helpful, kindly share it and show your support :)

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.
  1. Go to WHM
  2. Click on EasyApache 4 under Software
  3. Click on “Customize” button of your profile
  4. Click on “Apache modules” and find mod_deflate and enable
  5. Click on “Review”
  6. Click on “Provision”
  • You can follow below steps to enable gzip compression in cPanel.
  1. Login to cPanel
  2. Click on Optimize Website under Software. This will allow you to compress your web contents using different options.
  3. 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;

Application - application/atom_xml, application/atom_xmlt, application/x-httpd-php, application/x-javascript.

Image - image/svg+xml, image/jpg , image/jpeg , image/png, image/bmp,  image/gif , etc.

Text - text/css, text/html, text/javascript, text/xml
  • 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.

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/
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 image/jpeg
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/bmp
AddOutputFilterByType DEFLATE image/jpeg,
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE audio/mpeg
AddOutputFilterByType DEFLATE audio/*
AddOutputFilterByType DEFLATE video/mp4

You can test if the gzip compression is working on your site at


Mohammed Noufal

I'm Mohammed Noufal, working as Server Admin for the last 10 years.  In my day-to-day life, l had to face different problems related to Web-hosting. On my website, you can find solutions for different Web-hosting-related problems. Sometimes, I spent hours searching/googling to find a solution. This inspired me to start a website that gives solutions to different Webhosting problems. This website includes basic Linux and windows commands, and different control panels like cPanel, Plesk, DirectAdmin, Webmin & so on. You can find solutions and or suggestions for different Web-hosting related problems from here. Hence I would like to say Errorlogz is your server protector.  I will be glad if Logdetect can help any one of the Server admins to find a solution to his problem.

You may also like...

2 Responses

  1. Scott Aadal says:

    Sorry bro, but this is not working

Leave a Reply

Your email address will not be published. Required fields are marked *