This article describes how to enable data compression using Apache's mod_deflate module. You can use the mod_deflate module to compress output from your web site that is sent to client browsers. Using data compression can reduce page load times and the amount of bandwidth your site uses.
To enable data compression on cPanel-based hosting accounts, follow these steps:
On the Optimize Website page, under Compress Content, select one of the following options:
For unmanaged hosting accounts, you must edit the .htaccess file to enable data compression. The following sample configuration demonstrates one way to enable data compression by specifying file extensions:
<IfModule mod_deflate.c> <filesMatch "\.(js|css|html|php)$"> SetOutputFilter DEFLATE </filesMatch> </IfModule>
In this example, Apache compresses any file that has an extension of .js, .css, .html, or .php.
Alternatively, you can use MIME types to specify which files to compress. The following sample configuration demonstrates one way to do this:
In this example, Apache compresses any file that uses one of the MIME types referenced by the AddOutputFilterByType directive.
To disable data compression, you can delete the relevant lines in the .htaccess file, or comment them out by preceding each line with #.
To verify that data compression is active, please see Determining if compression is enabled below.
To check if data compression is enabled on your site, go to https://checkgzipcompression.com and type your domain name in the text box. The site tells you whether or not compression is currently enabled.
For more information about the mod_deflate module, please visit http://httpd.apache.org/docs/2.2/mod/mod_deflate.html.