A Web.com Partner
Sign Up / Log In
Online Support Web Hosting

How to Enable Gzip Compression

There are several ways to increase a website’s speed. Enabling GZIP compression from the server is one standard practice. While GZIP is commonly known as a file format, it is also a software application responsible for reducing the size of files (HTML, stylesheets, JavaScript, etc.). It allows a server to provide compressed files to the browser for a faster network transfer. This is an easy way to optimize your website and improve user experience.

You can enable GZIP compression using two different Apache mods: mod_deflate and mod_gzip. Both allow compression from the server before files are sent to a browser. However, mod_deflate is recommended. It is more widely supported than mod_gzip. In addition, it is documented better and configured easily. If it’s dysfunctional, you can use mod_gzip. We have provided both Apache mods below for your reference.

Enable GZIP compression

Here's a detailed instruction to enable GZIP compression in the .htaccess file:

  1. Access the File Manager.
  2. Locate the public_html folder on the left menu panel. Select the folder of the domain name you wish to manage.
  3. Click the .htaccess file, then select Code Editor button at the upper part of the page.
    You may also right-click .htaccess, then select Code Edit.
  4. Add one of the following scripts inside the .htaccess file:

    Enable mod_deflate (recommended):

    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    </IfModule>

    Enable mod_gzip:

    <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    mod_gzip_item_exclude mime ^image/.*
    </ifModule>
  5. Click the Save Changes button at the upper right-hand corner.

Please let us know if you need any further assistance, or if you have any questions. We'd love to help!

Was this helpful? Yes No 91% of people found this helpful.
{"message":""}