An Introduction to gzip / mod_deflate Updated on March 10, 2025 by Brad Markle 3 Minutes, 24 Seconds to Read mod_deflate is an Apache module that can be used to compress data using gzip compression before sending it to the user. For bandwidth intensive websites, using this feature can offer a benefit, as the server is compressing data before sending it you will be using less bandwidth. The major drawback to using mod_deflate however is that the server may need to use more resources to compress each file and this in turn can cause performance issues on older servers. As our shared accounts included unlimited bandwidth, using mod_deflate to reduce bandwidth usage is not usually a concern for shared users. It’s important to understand that gzip compression does not reduce resource usage on a server, nor is it guaranteed to reduce page load times for your website. To reduce possible resource usage and reduce page load time, a better solution is a caching option for your site. There are caching modules or settings for sites created with a content management system (CMS) such as WordPress, Joomla, Drupal, etc. Please note: Due to the performance issues that can be caused by mod_deflate, it should not be used on older shared servers. Contact Live Support for more information about your hosting account and how to migrate to a new Linux server hosting plan. How to Install mod_deflateHow to Use mod_deflateEnabling mod_deflate (gzip Compression) in cPanelEnabling mod_deflate (gzip Compression) in .htaccessHow to Test if mod_deflate is WorkingIssues with PHP 7 Table of Contents How to Install mod_deflate How to Use mod_deflate Enabling mod_deflate (gzip Compression) in cPanel Enabling mod_deflate (gzip Compression) in .htaccess How to Test if mod_deflate is Working Issues with PHP 7 How to Install mod_deflate The mod_deflate Apache module is already installed on our shared hosting servers. cPanel VPS and dedicated server administrators can install the HTTP compression module in WebHost Manager (WHM). Log into WHM as root.On the left select “EasyApache 4.”Beside “Currently Installed Packages,” select “Customize.”Select “Apache Modules.”Search for “mod_deflate.”Select the mod_deflate toggle switch to turn it blue.Select “Review.”Select “Provision.” Cloud server administrators can use the following command to see if the Apache module is already installed and enabled: apachectl -M | grep deflate If the output states “deflate_module (shared)” then it is installed. How to Use mod_deflate To use mod_deflate, you have two options: Use the Website Optimization option in cPanelAdd a few lines to your .htaccess file Enabling mod_deflate (gzip Compression) in cPanel Under Software/Services in your cPanel click on the Website Optimization icon. Select Compress all content or specific MIME types. To limit which types of content are compressed, choose Compress the specified MIME types and input the particular MIME types you want to compress. If you specify particular MIME types, it is best not to add image, video, audio, PDF or other types of binary files. These file formats are already compressed, so it is not necessary to compress these further. Once you have chosen your settings, click Update Settings to save your changes and enable gzip compression on your account. To turn off gzip compression, select Disabled on the Website Optimization page and click Update Settings. Enabling mod_deflate (gzip Compression) in .htaccess Edit your .htaccess file and add the following code: AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript How to Test if mod_deflate is Working There are several sites online that you can use to help test whether mod_deflate is working for your site or not. One site we found rather easy to use is https://www.whatsmyip.org/http-compression-test/. All you need to do is enter your domain and click the “Test” button. Below we have showed before and after screenshots that indicate whether mod_deflate is enabled. URL compression test failed URL compression test successful Issues with PHP 7 Various users have reported issues involving the cPanel Optimize Website button and performance with PHP files. This seems to have affected websites using PHP version 7 and up. If you are having trouble using the compression features available from cPanel, you can try making these modifications in your php.ini file. output_handler = Off zlib.output_compression = On zlib.output_handler = ob_gzhandler Reliable Shared Hosting for Growing Businesses Get the performance your business website demands with NVMe SSD storage, industry-standard cPanel management, and direct access to hosting experts whenever you need assistance. Free Website Migration 24/7 Human Support 100% Money-Back Guarantee Shared Hosting Share this Article Related Articles Intro to Migrating your WordPress Site Data Migrating your WordPress Database Migrating WordPress Files Configuring WordPress After a Migration Testing your WordPress website after Migration How to Move WordPress from a Subfolder to the Root Directory What to expect during a mass server migration Move Your WordPress Site to a New Server Moving Websites Built with Older Technology into WordPress How to Export Your WordPress Sites
As per GTMetrix (https://gtmetrix.com/enable-gzip-compression.html), they say you need the tags and . Do I need to do that in conjunction with the code shared on this page? AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript Furthermore, do I add it outside/after the element? Thanks!
Hello and thanks for asking. It can be helpful depending on what types of files you have your website. You can add them all within the same section.
When you say “can cause performance issues on older servers“, what apache server versions are you referring to ? I am planning to use mod_deflate for website (mostly static) hosted on apache server. Would you suggest using mod_deflate for Apache 2.0.x OR 2.2 & above ?
Hello Aniruddha, As noted above, this issue has to do more with the version of cPanel being used where mod_deflate is not present. So, if you don’t see the Optimize Website in your cPanel, then you know you’re on an older server. According to this Apache HTTP Server post, using Apache 2.0 is okay though it is no longer supported. Version 2.4 should be okay. If you have any further questions or comments, please let us know. Regards, Arnel C.
I have added ini_set(‘zlib.output_compression’, ‘On’); ini_set(‘zlib.output_compression_level’, ‘1’); with and w/o php tags and it broke the site.
Well in the cpanel , most of the times you have the Optimize website option. That is the GZip function . all u have to enable it .. Hope it Helps. Many Thanks
Hi, I am having shared hosting linux account & it does not have “Optimize Website” option in Cpanel. Also i added mod_deflate code in .htaccess file. But still my website https://www.bismicaterersperambur.com/ not compressed. Can someone help me out for this issue ?
Hello Muhammed, Are you one of our customers? This option should be within your cPanel if you are. If you are not, you may want to see if they have another option. Kindest Regards, Scott M
Hi , I have a Magento website . Is it safe to turn on Website optimisation – from Cpanel . I only Plan to compress html and xml . Will it be safe . do i need backup before enabling it thanks
Hello Bankim, That should be fine, but you should definitely back up the site beforehand just in case. Kindest Regards, Scott M
I am new to CPanel and i have to redirect IP address to Domain Name of my comany website, how can i do this using CPanel? And i already tried .htaccess code but it’s not working….. Thanks in advance
Hello Advante360, Sorry for the problem with the re-direct. Your question is on the wrong page within our support center. You should go to the 301 Permanent Re-direct page for more information. The re-direct in .htaccess will be the best way for you to make this happen. The cPanel re-directs simply write the code in the .htaccess for you. If you’re using an IP address, then you edit the .htaccess file directly. Remember that the re-direct should be at the TOP of the file since actions within the .htaccess file are done within sequence. If there’s a conflicting rule, then it may bypass your re-direct causing it not to work. If you require further assistance with the issue, please post a reply with either your URL(if you are an InMotion customer), or further information on the code being used in the .htaccess. If you have any further questions or comments, please let us know. Regards, Arnel C.
I’ve been reading about this GZIP compression for about an hour or two now and so far I got it to work. But there’s one thing I still don’t get. Is there a difference between enabling GZIP(mod_gzip) and mod_deflate or is it all the same thing. Just been reading a article about this on another website (https://www.giftofspeed.com/enable-gzip-compression/ ) which says there is a difference between the two mods. Anyone to help me explain this?
Hello Marlin! Great question! This is well discussed on the internet and in the responses above. You can a great discussion as well as reference links by going here. However, to summarize the issue: mod_deflate and mod_gzip use the same compression algorithm, but in different ways. Mod_deflate is configured to compress files differently (using gzip) than mod_gzip. If you want a really thorough breakdown, check out the Linux Journal article on using mod_gzip and mod_deflate. The article clearly states that when you compress with either method, you’re using gzip. However, for issues of performance, mod_gzip is better with the shared server as it uses less CPU. Both of these options have pro’s and cons, but it appears that InMotion recommend using mod_gzip. I hope this helps to clear up the issue. If you have any further questions or comments, please let us know. Regards, Arnel C.