Having a website that loads up quick does not only offer your clients a better experience, but is also an asset for better Google indexing. A website has multiple parameters that can be optimized in order to deliver content more quickly. In this article I will explain the simplest of them, Gzip compression. By enabling Gzip compression, the web server compresses your web pages, resulting smaller sized content that is faster delivered to web Browsers.

 

Enabling Gzip Support on cPanel Server

Firstly, you need to make sure Apache is build with Deflate module. This can be checked by running the following command in SSH as root:

httpd -M | grep deflate

 

 

If the output of this command also contains:

deflate_module

 

 

Then Apache is built with deflate support, if not you need to add it through EasyApache (WHM > Software > EasyApache > Customize profile > Exhausite options list) > Check Deflate > Save & Build.

Having mod_deflate active on your server is not enough to serve compressed gzip content. You will need to take one more step:

WHM > Service Configuration > Apache Configuration > Include Editor > Pre VirtualHost Include > All Versions. In the content box that opens, you will need to add these rules:

<IfModule mod_deflate.c>
# Insert filter
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>

<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

 

 

 

 

 

 

 

 

 

 

 

 

Press Update > Restart Apache

Congrats! Now your websites will deliver gzip compressed content.

Leave a Reply