What is mod_deflate?

How mod_deflate works

When a visitor accesses a website, a request is made to the web server for a specific kind of data. An example might be a home page of a site. Next, the web server locates that data and delivers it to the client who is requesting that data – basically back to the web browser.

In this example, the speed at which the home page loads can depend on a variety of factors. One of them could be how long it takes to find and deliver the data for that page. This is just one example.

Some of that data – such as javascript files, css files, and php files – can actually be compressed into smaller sizes before they are delivered back to the visiting client or browser at the smaller size. The visitor can now have a more optimized browsing experience.

This is where mod_deflate comes in.

Using mod_deflate

In order for mod_deflate to work properly, two things need to happen:

  1. It needs to be installed on an Apache v2 server
  2. It needs to be configured or setup on the server

Using mod_deflate will require some configuration, so you may wish to have a developer configure that for you. If you have a server at Liquid Web, one of our Helpful Support Technicians would be happy to install this for you.

Not all server environments can utilize mod_deflate, as it is a module (add-on) to work specifically with the Apache Web Server.

Here are some things to keep in mind when setting up mod_deflate:

  • It is compatible only with an Apache Web Server, and only on Apache V2.
  • It will require that the module itself is installed directly on the server environment.
  • You can configure it by placing certain directives in an .htaccess file.
  • If you have worked with older versions of Apache, you may have worked with a very similar module called mod_gzip. Mod_gzip also compresses data before it leaves the server; only specific types of data can be compressed.
  • Only compress data that is already uncompressed, so the module is not trying to compress something that is already reduced in size through compression.
  • There can be a slight CPU load in exchange for compressing data. You will want to test your specific environment to see how compression affects web traffic speed improvements versus web server resources.
  • Smaller files leaving the server equals lower bandwidth, which is good news for most, especially if outgoing bandwidth costs are an issue.

Next, let’s look at how to install mod_deflate in WHM on a Centrol 7 with Easy Apache v4.

Installing mod_deflate in WHM on Centos 7 with Easy Apache v4

  1. Find EasyApache 4 in WHM
    Login to WHM and type “apache” in the upper left search field. Once the menu adjusts to that filter, click on EasyApache 4.
    We’ll want to customize our EasyApache 4 setup, so find and click the blue Customize button.
    This will load the current Apache profile.
  2. Find the mod_deflate Module
    You will need to load more modules on the page, or even all of them, to find the mod_deflate module. Once you find it, toggle it on. Click on Apache Modules in the left menu to load the Apache Modules. Next, change the drop down menu to show 50 items per page.
    Scroll down through the Apache Modules until you find mod_deflate. Turn it on.
  3. Review and Provision
    Now, go to the left menu and click on Review. One you click, EasyApache 4 will review all of the changes you have made to the current EasyApache 4 profile. It is as simple as that!
    Finish the review by clicking on the Provision button toward the bottom of the page.
    EasyApache 4 will now add the mod_deflate, and provision all of the changes. Once it is finished, you will get a confirmation – at which point you can click on the blue Done button.
  4. Check the Installation
    You can confirm that mod_deflate is installed by going back to EasyApache 4 and clicking on View All Packages.
    That’s it! The server now has mod_deflate installed. Don’t forget – you also need to configure to server to use this module.

Configuring mod_deflate

  1. Find the Include Editor in WHM.
    Log in to WHM and go into Service Configuration -> Apache Configuration -> Include Editor.

  2. Add the mod_deflate rules
    Within the Include Editor, go to the Pre VirtualHost Include area. Select All Versions, and add the following:

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

  3. Save Changes
    Remember to save your changes, and then restart Apache. If you are a Liquid Web customer, we can do this for you! Congratulations and happy faster load times!

Have a WordPress site you want to go faster? Check out the following articles!

https://www.liquidweb.com/blog/how-website-speed-can-keep-you-out-of-trouble/

https://www.liquidweb.com/blog/speed-website-drive-traffic/

Be Sociable, Share!
    Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support