What is mod_deflate?

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. If your site is created with a Content Management System such as WordPress, Joomla, Drupal, etc.; there are modules or settings for each of those that will enable caching for your site. For example, the WP Super Cache Plugin will help you optimize your WordPress site. In Joomla, caching is a built-in module which you can enable in your Joomla administration panel.

Please note: Due to the performance issues that can be caused by mod_deflate, it should not be used on older shared servers. If you do not see the option for Optimize Website in your cPanel, you are on an older server that does not support gzip compression (mod_deflate).

How do I install mod_deflate?

The mod_deflate apache module is already installed on our servers.

How do I use mod_defalte?

To use mod_deflate, you have two options:

  • Use the Website Optimization option in cPanel.
  • Add 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:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

How can I 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:

http://www.whatsmyip.org/http-compression-test/

All you need to do is enter a URL and click the "Test" button. Below we have showed before and after screenshots that show when mod_deflate is enabled, and when it is not.

when-mod_deflate-is-not-enabled when-mod_deflate-is-enabled
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
2012-04-27 2:35 pm
For those on shared InMotion hosting, I've added the following code snippet to the top of my WordPress themes' header.php files in order to achieve Gzip compression:

<?php ini_set('zlib.output_compression', 'On'); ini_set('zlib.output_compression_level', '1'); ?>

So far I haven't run into any performance issues.
1,344 Points
2012-04-27 3:00 pm
Hi Teebird,

Thank you for the input. Modifying your core WordPress files is not recommended, and in this case is not needed. You can simply add the code shown above to your .htaccess file (either before or after any code added by WordPress).

Please let us know if you have any questions or need any assistance.

Regards,

Christi N.
2012-04-27 3:19 pm
Hi CNick,

I would use the above method if I wasn't on a shared hosting plan. The tutorial above says that mod_deflate is NOT recommended for InMotion shared hosting:

"Please note: Due to the performance issues that can be caused by 'mod_deflate, it should not be used on our shared servers', and instead only be used on VPS and Dedicated accounts. Also, as our shared accounts included unlimited bandwidth, this further reduces the need to use mod_deflate to reduce bandwidth usage."

Also, I don't believe files in a Wordpress theme are considered a part of
the WordPress Core files. :-)

The method I am using is also pretty common among wordpress users: http://bit.ly/IpEOOC

Thanks
1,344 Points
2012-04-27 4:04 pm
Hi Teebird,

We apologize for the confusion. That note mod_deflate on shared servers was in reference to older shared servers that do not support mod_deflate. I have updated the article to clarify this.

While your theme files may not be technically core files (I apologize for the incorrect reference) if you are not using a Child Theme and your theme is updated, your changes could be overwritten and lost.

To speed up WordPress, a caching plugin like http://www.inmotionhosting.com/support/edu/wordpress/recommended-wordpress-plugins/optimizing-wordpress-with-wp-super-cache is a preferred solution.

Regards,

Christi N.
2012-04-27 5:39 pm
Ah, thanks for the update and good points about WP theme updates.

I have gzipped my InMotion sites via "Software Optimization" wizard in my cPanels. Thanks! :-)
1,344 Points
2012-04-30 10:23 am
You're welcome Teebird. Thank you for bringing this to our attention so we could clarify the information.

Please feel free to contact us anytime you have questions or need assistance. We're always happy to help!

Regards,

Christi N.
2013-04-04 8:22 pm
I have been unable to get compression to work. I have a VPS, and I don't have the Software Optimization option. I added the code to my .htaccess (and tried other code I found on Apache's site), and I still fail the compression test.

What am I doing wrong?

www.alvingolf.com
Staff
16,683 Points
2013-04-04 9:12 pm
Hello Farreldoc,

I was looking at your account along with a Systems person, and we discovered that you do not have DEFLATE setup on your server. Therefore, none of the optimizations (using gzip) would work. You can install it yourself since you have root access, or you can send an email request to support@inmotionhosting.com. Make sure you verify the account in the request with either the last 4 digits of your credit card or the AMP password.

If you require further assistance please let us know!

If you have any further questions, please contact technical support available 24 hours a day / 7 days a week.

Regards,

Arnel C.
Community Support
2013-07-04 5:52 am
Thanks, Brad. Very useful notes. I added to our .htaccess file on our web site http://www.itware.com the instructions you see at the bottom of this message, sligtly different oy yours, but it seems they work perfectly.
My question is: why the Joomla developer team doesn't include this code by default on the .htaccess file? All Joomla webmaster could save a lot of time, expecially the ones at the beginning of their experience, just like me: we got a very poor ranking from Google Page Speed, so I worked about solving the several items they put in the "to do list". I found your note after several hours of navigation.
Why don't you suggest them this improvement?
Thanks
Ciao
Alessandro

#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip
Staff
5,399 Points
2013-07-05 12:03 pm
Hi alegiac,

This compression isn't enabled in most programs by default because in addition to its benefits, it has its drawbacks as well. While compression sends smaller files to the end user, the server has to work hard to compress everything it's sending. Some servers, especially those getting lots of traffic, may ultimately fail / crash if they can't keep up with all of the compression requests.

So, basically, gzip compression can be really hard on servers in some situations, and sometimes the consequences are worse than the benefits that can be gained.

Does that make sense?
2013-07-06 11:28 am
Yes, off course! Thanks Brad. You are certainly rigjht, even if today CPU power is not anymore a big constrain. Thanks indeed
Alessandro
n/a Points
2014-04-28 5:48 pm

Sorry to revive such an old topic but it does seem to be one of the more 'up-to-date' ones regarding gzip and mod deflate.  In light of BradM's response, I was wondering therefore if there a critical point where if a site reaches a certain size or traffic, then gzip compression should not be enabled?  Or does this also depend on the server it resides on?

Thanks in advance :)

Staff
9,968 Points
2014-04-28 6:44 pm
Hello Flick, we love it when an old article gets some new comments so thanks for that!

The critical point where you would want to figure out if gzip is going to really help you or not, is really going to depend on the content of your website itself, as well as the amount of CPU usage you have available to your account.

For instance if you have very high traffic to your website, and you primarily serve up dynamically generated pages from something like PHP that are rather large in size (> 200K), having the server compress that data on the fly can be a bit taxing and lead to higher CPU usage. Also if you are trying to serve up images using gzip compression that have already been compressed for the web, this can waste CPU time doing unnecessary work. This is why in this guide it just mentions enabling the compression on plain-text files instead of everything on your site.

In most cases having gzip compression turned on is a good idea all around. If you are on a shared hosting account you'd just want to view your resource usage to ensure you're not taxing the server's CPU resources too much. If you are on a VPS or dedicated server with more resources, more than likely you won't run into any issues at all with it enabled for your sites.

Hope that answered your question, let us know if you had anymore!

- Jacob
2014-07-16 4:58 pm
This is ALL making my head hurt... as a beginner, I don't understand most of all this tech talk... and wish someone from IMH would just take over our sites for 10 minutes and FIX all these technical things to WPress, server settings, cache, and all the other things that are evidently hurting BOTH of us. The problem is it takes a beginner a month to even figure out what to do, and wasting the techs time etc... I am reading OLD info mixed in with new and that is making it worst. I am ready to scream.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

14 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!