Deploying mod_deflate On Your Apache Web Server

Sunday, November 22nd, 2009

If you are closely tuned in to the web world as I am, you may have heard that Google may include “web page load time” as one of their ranking factors in 2010. I heard about this, saw a few videos about this and read about this. Apparently, when Google talks about changing what makes people’s websites rank differently, people listen…and then talk about it themselves.

I run a bunch of different websites. Some of them have rather large page sizes. The reason they are so large is because of additional files beyond simple HTML that each page pulls in to make the web page behave correctly. These files, such as .js and .css files can get kind of big. Over the years, I didn’t really dig too deeply into the page size issue because the sites get fairly good traffic. I just let things ride.

A few days ago, I came across a post on a forum that talked about mod_gzip or otherwise known as GZIP. This is software that you can install on your web server that compresses your web pages up to 70%. Google recommends that webmasters use GZIP to speed up their websites. Google likes to present its visitors with nice speedy pages in their search results.

I read that it’s pretty easy to deploy GZIP and that it really shouldn’t take more than a few minutes (if it’s already installed on your server). I decided to give it a try. So I did. It didn’t work. Hmmm.

I called my web host and started asking questions. I was like, YO B%^&*, what up with my GZIP??? No really, I was polite. I asked about why GZIP wasn’t giving me any compression results and they told me that I was running Apache2 and that mod_deflate was already installed, not mod_gzip. All I needed to do was to deploy it. I kind of like the name “GZIP” better than “DEFLATE” but who am I to argue?

By the way, here are some good resources on using GZIP and DEFLATE:

- How To Save Traffic With Apache2’s mod_deflate
- Mod_Deflate vs. Mod_Gzip , Comparing the Two

First, I asked the web host to deploy mod_deflate on only one domain. I wanted to gauge the results and also take a night to see if anything got screwed up from it. They were agreeable and did the following:

At your request I enabled mod_deflate for one domain on server 123456:

http://www.mydomain.com/

This was done by modifying:

/my/path/mydomain.com/conf/vhost.conf

with the following content:


AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript

I checked the website in questions and low and behold, I saw web pages that were being compressed. How could I tell? I used these resources:

- Port80 Software Compression Check
- Web Page Analyzer – 0.98 – from Website Optimization

I checked out some stuff overnight and since everything looked fine in the morning, I gave the web host a call back and asked them to undo what they did to that individual domain and set it up server-wide. They put the server back the way it was and set up mod_deflate to compress all the websites on the server by doing this:

Created a file /my/path/mod_deflate.conf with the following line:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript

That was about it. Since Apache2 comes with mod_deflate installed already, all we had to do was to deploy it. We did this both for an individual domain and server-wide.

I bet you want to know about the results, right? Okay. Well, I can tell you that I had some web pages that were over 400kb. They are now running at about 165kb. I also had some web pages that were about 445kb. They are now running at about 45kb. That’s about 10% of what it was. Is that crazy? Yes, it’s nuts.

Next week, I am going to deploy mod_deflate on my other web server. That should really make some positive changes.

There are a few things you should know. The first thing is that if you decide to do this and have a cable internet connection where you are connected to the internet, you most likely won’t notice much of a change. I read that this has something to do with packets. I am not that smart, so I just took this statement as face value. Although, I run cable and didn’t really notice much of a change. People who use DSL and dial up will definitely see some speed improvements from the smaller web page sizes.

Also, if you are running a website and are using a shared server, you may not be able to use mod_gzip or mod_deflate. Since both of these modules use an increased amount of processing power, many web hosts won’t allow its use. If you aren’t aware, some of these web hosts pack like 10 billion websites on each server. Any increase in CPU demand is going to cause problems. Still, you should give them a call to see what they say. You might get lucky.

Related posts

How to Set Up a Custom 404 File Not Found Page

Wednesday, September 17th, 2008

Ok, this is a pretty simple thing to do and it has some important benefits.

Have you ever visited a website or a web page only to find that annoying “Not Found” error message? If so, what did you do? You probably got ticked off, hit the back button and visited another website. Can you imagine someone coming across a “Not Found” error page on your website? Well, if you don’t have a custom 404 “File Not Found” page set up on your website, that might just be happening.

Here is what you need to do to fix this problem and keep your visitors on your website.

The first thing is to create a web page with some sort of message on it. Something like, “Whoops, looks like the page you are looking for isn’t here. Please click this link to visit our home page or our search page…” You get the idea. You can save the page as “404.php” or something similar and upload it to the root of your web server.

Oh, I forgot to mention this. In order to do what I am suggesting here, you need to be running an Apache web server and your web host has to allow changes to your .htaccess file. I am sure there are other ways to create a custom 404 File Not Found error page and get it up and running, but I am only talking about one way here.

Now, open up your .htaccess file and place this code into it somewhere. I like to place it right on top:

ErrorDocument 404 /404.php

I am using .php extensions for this stuff just because of habit and preference. You can use .html or whatever you wish.

Well, that’s basically it. You can now save your .htaccess file and upload it to the server and go see if it worked. Try typing in some page that you know isn’t there. If it works, please read my previous post about “How To Check Your Web Page HTTP Headers & Response Codes” for some important information.

Good luck.

Related posts

Upgrading From PHP4 to PHP5

Saturday, January 12th, 2008

Again, I read the writing on the wall.

One of the companies that created some of my website applications recently put a web poll in their forum. They asked how we users feel about having the next upgrade (and every one thereafter) only work with PHP5 and up on our web servers. I didn’t know what to think. I believe I was running PHP 4.3.8 on a few of the servers and some other version of 4 on the other servers. I didn’t know how all of my 30+ websites would respond to a PHP upgrade.

To find out, I did a little configuring in the .htaccess files on two of my websites. By doing this, I automatically brought the version up to PHP 5.2.4. If things blew up, I could easily bring the version back down to PHP4 by taking that line of code out of the .htaccess file.

Well, I tried it out and everything worked fine, except for two little files that an outsourced developer created for me. I contacted him and he fixed the issue rather quickly. Since I knew things would be ok, I went ahead and had one of my other servers upgraded to PHP 5.2.5.1. After the upgrade, everything worked fine on all my websites.

So, what is the difference between PHP4 and PHP5? You can click here to find out.

Related posts




Free Online Ads
Motorcycle Classifieds
Boats For Sale
Free Auto Ads
Free Pet Classifieds
Free Classifieds