gzip/deflate – a (fairly) quick how-to for XAMPP
I’ve spent a little while trying to figure out the difference between using “deflate” and “gzip” for web-compression. What I’ve finally ended up with is they are pretty much the same thing (well they use different compression methods, but seriously, they do just about the same thing). I also noticed that if you are running Apache 1.3 your compression options pretty much are gzip, and if you are running Apache 2 you pretty much only have deflate.
I searched all over for someone who knew how to set this up so I could have it on my local dev box (I’m currently running one of the XAMPP packages). I didn’t find the answer anywhere, what I did find was plenty of people telling me to create a .htaccess file and everything should be good. Or links to the Apache documentation on using deflate (which while helpful, is pretty much a standard doc… so-so in the “I’m not really sure what I’m doing” department). Believe it or not I found the answer in the depths of a linux tutorial site. So I’m posting the run down in case you want to play with compression on your own site.
- You need to make sure that you have the mod_deflate plug-in enabled on your web server. For XAMPP users this is found in the /xampp/apache/conf/httpd.conf file. Mine was actually on line 93 of the file, it was there, just commented out (with a #) so I took off the comment and now the line reads “LoadModule deflate_module modules/mod_deflate.so”
- Now you need to restart your web server
- Let make (or modify) a .htaccess file. To enable the compression you need to add this to your .htaccess file.
SetOutputFilter DEFLATE
- Make another .htaccess file in your js directory (or just tack on another ‘Files’ tag) and replace the “*.html” with a “*.js”. That will enable compression on your js files (Also noted that if you used a packer (like the excellent dean-edwards packer) this might screw up your script or cause your page not to load. The best idea for js compression is to minify it and then use this deflate or gzip compression on it. (see a previous post about js compression to find links
) - And you’re done. Seriously, that’s it. It’s that simple. Why no one on the net had posted that is beyond me. You should now be done and you can go and check your work by cracking open a page on your web server and checking the page size. The easiest way to do that is to use the Firefox Web Developer Add-on and click on the “Information” button then click on “View Document Size”.
So for my own site (a webapp called the WebTop) here is what I ended up with. Without deflate compression enabled my page was 134k, with a massive 94k of that being various js files. and 17k being chewed up in html files.

With the compression turned on however, we managed a very acceptable 56k for the site. The html being compressed down to 4k, and the js files being crunched down to 29k.

Jason said,
I found that instead of putting “SetOutputFilter DEFLATE” in a .htaccess file you can instead put at the bottom of “/xampp/apache/conf/httpd.conf” file to auto-load during start-up.
Phil said,
@Jason Thanks for the tip, it’s nice to have compression on auto so you don’t have to pack around .htaccess files from project to project.
Keith Davis said,
Good to find a site with info on XAMPP local server setup.
I’m using XAMPP to set up a WordPress site before going live.
I’m getting to know the cforms plugin but can’t get it to send an email… do I have to change some of the XAMPP settings?
Hope you don’t mind me asking a question not related to the post.
Phil said,
@Keith Davis
You may need to change some settings, it’s been a while since I’ve used the built-in mail server of XAMPP (Mercury Mail). Problems with email are usually a beast to chase down (as I’m sure you are fully aware), they can range from a php configuration error, to unrecognized MX records when you try to send.
First thing I would check is that I had my mail server installed and running. Mercury Mail comes bundled with XAMPP, but is not enabled by default.
See here for a blog post about setting it up (and testing with Thunderbird).
Check this post for another set up list (with some edits to your php.ini file, don’t give up, xmapp has about four of them).
If you follow those and still run into issues, it may have to do with the cforms plugin, or another server bouncing your email as spam (lack of legit mx records).
Hope it helps,
Phil
thofik said,
what tools to test the gzip
Phil said,
@thofik
Sorry for the delay in replying, to test if your gzip is working I recommend using the “web developer” addon for Firefox. You can find thathere. There are other tools you can test with, both Chrome and Safari have developer tools that will show you what is being downloaded, the time it takes, and the file size. Another option you may want to look at is PageSpeed (by google), or Yahoo’s YSlow.
Hope that helps.
Add A Comment