How to enable gzip compression in cPanel

Compressing web content is an effective way of speeding up the page load times, save bandwidth, and improve the user experience. This article shows you how to activate and customize gzip compression in cPanel and how to use online tools to confirm that it is working.

The compression reduces the size of the file before the web server sends them to the internet browser. The process of compressing and decompressing takes less time as compared to sending large files over the internet. Once a browser receives them, it decompresses them before displaying the web pages.  This allows you to provide faster load times and a better user experience.

One of the standard methods is to use gzip compression in cPanel. Enabling the feature at the cPanel level allows you to automatically compress all the supported files for the domain or website in that hosting account. This can reduce page size by over 70%.

The compression relies on the Apache mod_deflate module. If unavailable, you may need to request the host provider to install it for your account. You can also install it yourself and apply to all cPanel accounts under your package if you have the WHM administrator’s rights.

Enabling gzip in cPanel

The gzip compression is usually disabled by default, and you need to log in to your cPanel and enable the functions using the inbuilt features. The two common the methods to enable the feature are;

  1. Using the Website Optimization tool
  2. Editing the .htaccess and adding the relevant commands.

Using the Website Optimization tool is a more straightforward method. For the .htaccess method, you can either use the cPanel or a terminal to access or edit the file. But for the purpose of this article will discuss hot to access and edit .htaccess using the File Manager in the cPanel.

  • Log in to your domain cPanel using the format or
  • Enter your domain account username and password
  • Navigate to the software section and open the Optimize Website option. This allows you to compress your files using different options.

Please note that the compression feature requires first enabling the Apache mod_deflate on the server. This is usually done by the hosting provider and you can request the host to do it if disabled.

The Optimize Website feature opens a Compress Content window with the following three options that allow you to disable the function, compress all the content or specific types of files.
These available options are;

  1. Disabled: This is the default option
  2. Compress All content: This allows you to reduce the size of all the website components that a browser or web application requires. Selecting this option will compress the entire content on your website.
  3. Compress the Specified Mime types. This allows you to specify the type of files that you want to compress. A MIME type requires you typing the syntax in the format type/subtype.  Where the type represents the category which can either be discrete or multipart. You can specify the MIME type in any case, but lowercase is more common.  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/javascripttext/xml

A typical selection for different types of text files will look like text/html text/plain text/xml, etc.

  • Select the option you want to implement by checking its radio button and Update Settings to save.

Saving will display a message indicating the type of content that the server will compress. For example, if you select the Compress All content, you will see the message “Content compression is now enabled for all content”.

Similarly, if you select the last option, the message will show you the MIME types that the system will compress.

Enable the Gzip Compression service in the .htaccess file

Other than using the Website Optimize tool in cPanel, the other option is to use the .htaccess file and add the relevant codes.

  • Log in to the cPanel
  • Navigate to the Files section and open the File Manager

  • Locate the .htaccess file in the public_html folder or home directory of the domain or website.
  • Highlight the .htaccess file and click Edit at the top
  • Alternatively, right-click on the .htaccess file and select Edit

    This will open an editor window that allows you to add or remove the code in the .htaccess file. If the file is not there, you can still create a new one by pressing the new file icon in the file manager.
  • Once you open the .htaccess in an editor, you can then proceed to enable gzip compression for specific files such as text, CSS, HTML, JavaScript, XML, video, audio, image, etc.
  • Add the respective code to the website’s .htaccess file in the format;  AddOutputFilterByType "MIME type"For example, to compress MIME type files text/plain add the line
    AddOutputFilterByType DEFLATE text/html
  • To compress different types of files, use the above format for each file type.  Below is an example of code that works compresses application, image, and text, audio and video files. Add the following code to the .htaccess file, and you can change them to meet your needs.
    <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
  • After you are through with specifying the type so files to compress, click Save Changes and then Close.

Test if GZIP compression is working

Enabling gzip compression allows you to save at least 50 % bandwidth, but how do you confirm this?

Once you configure the compression, you can test and see if it is working through a number of free online tools. Most of the tools will confirm if the feature is enabled as well as the amount of the reduction it achieves. Below are some common tools that you can use.

Test compression using Check GZIP compression

The tool scans your website and will confirm if the GZIP is enabled or not. It also provides you with both the uncompressed and compressed sizes, as well as the percentage of the reduction.

If you have a domain where compression is disabled, the tools will display the message “GZIP is not enabled”, the uncompressed and compressed sizes as well as the potential savings.


As a domain owner, you can improve your website performance by enabling the gzip compression feature in the cPanel.

The simplest method is to use Website Optimization method that allows you to choose to compress the entire website or specify a particular type of files. The other method is to add some lines to your .htaccess file and specify the type of content to compress.

Once you enable compression you can use a number of free tools to confirm that it is working and also see the percentage size reduction.

The overall effect of compressing your website content is fast load times, lower bandwidth requirements and better user experience.


Check out these top 3 cPanel hosting services:

Was this article helpful?