Follow On

How to enable gzip compression in cPanel

Share on facebook
Share on twitter
Share on pinterest

Enabling gzip compression in cPanel can help improve your website’s performance by reducing the size of files sent from the server to the client. Here are the steps to enable gzip compression in cPanel:

Method 1: Using the cPanel Interface

  1. Log in to cPanel:
    • Go to yourdomain.com/cpanel and log in with your cPanel credentials.
  2. Find the Optimize Website Option:
    • In the cPanel dashboard, scroll down to the Software section.
    • Click on the Optimize Website icon.
  3. Enable Compression:
    • In the Optimize Website interface, you will see an option for Compress all content or Compress specified MIME types.
    • Select Compress all content to enable gzip compression for all file types. Alternatively, you can select Compress specified MIME types and enter the specific MIME types you want to compress (e.g., text/html text/plain text/xml).
    • Click the Update Settings button to save your changes.

Method 2: Editing .htaccess File

  1. Access File Manager:
    • In the cPanel dashboard, go to the Files section and click on File Manager.
    • Navigate to the root directory of your website (usually public_html).
  2. Edit .htaccess File:
    • Locate the .htaccess file in the root directory. If you don’t see it, ensure that you have enabled the option to show hidden files.
    • Right-click on the .htaccess file and select Edit.
    • Add the following code to the file to enable gzip compression:

# Compress HTML, CSS, JavaScript, Text, XML, and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
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 application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Save and Close:

Save the changes to the .htaccess file and close the editor.
Method 3: Using PHP.ini (if applicable)
Access File Manager:

In the cPanel dashboard, go to the Files section and click on File Manager.
Navigate to the root directory of your website (usually public_html).
Edit or Create PHP.ini File:

If a php.ini file exists, right-click on it and select Edit. If it does not exist, create a new file named php.ini.

Add the following line to enable gzip compression:

zlib.output_compression = On
zlib.output_compression_level = 6

3. Save and Close:

  • Save the changes to the php.ini file and close the editor.

By following these methods, you should be able to enable gzip compression on your website hosted via cPanel. Remember to clear your website’s cache and test your website using tools like GIDZipTest or Google PageSpeed Insights to ensure that gzip compression is working correctly.

About Us

ALPHABET DEVELOPERS LLP is a leading and well known IT company based in India that provides the quality services and solutions to its clients and customers by development design and implementing solutions.

Contact Info