Hi all! In this article we will tell you how to enable mod_gzip and make it work the way you want. The basics of the module are recounted in Introduction to mod_gzip. We’ll only remind that mod_gzip is used to compress response before it is sent to the client.
Having Helicon Ape installed, open httpd.conf file in Ape installation folder using Helicon Ape Manager. To be able to manage the module you should uncomment corresponding LoadModule directive, as shown on the picture:
IIS possesses its own facilities for GZIP compression. These must be disabled if you are going to use mod_gzip for these purposes. Helicon Ape has a lot more means for more flexible and fine configuring. To disable internal compression in IIS please run IIS Manager, in the tree on the left choose server or specific site. Now open ‘Compression’ element and put the ticks as shown below:
Now we are ready to start writing a simple config. Let’s enable compression for all requests first. According to the docs this may be accomplished in three ways. We’ll use environment variables:
The above line does the following: enables mod_gzip, allows compression for all types of requests, applies default compression level of 6.
Easy, isn’t it? “But where’s the flexibility you promised?” – you wonder. Not all files may be compressed to the same extent. It’s well-known for instance that text documents are more “compressable” than images. And for PNG, JPEG, GIF formats the benefit may tend to zero! And everything would be just great if the module’s operation didn’t take time. So why waste time to fruitlessly compress almost uncompressable files if we can simply say mod_gzip not to touch them. Let’s use mod_setenvif module to disable images compression:
SetEnv gzip SetEnvIf mime image/.* no-gzip
Much better this time, right? Yeah, better but not the best:) mod_gzip can do even more! Let’s play with compression level now. The default value is 6 but maximum is 9. And sometimes the difference is noticable. As we know the text is compressed well, let’s set it’s compression level to 9, we’ll still ignore images and everything else will be compressed by default:
SetEnv gzip SetEnvIf mime text/.* gzip=9 SetEnvIf mime image/.* no-gzip
Another situation may be that you want to compress only specific file types. Say you want only HTML/CSS/JS to be compressed with maximum compression level:
Note! If you previously were an Apache fan, the above syntax may surprise you. Yes, it’s true – it’s applicable only in Helicon Ape (for your own good). Here you may find more information on extended syntax.
But if for some reason you want your Helicon Ape config to be compatible with Apache, here the equivalent to what we’ve done before:
And the most delicious dish in the end;) We’ve made some kind of compilation of the most effective mod_gzip and mod_cache settings that you may use on your server as is. mod_cache is used to speed up the delivery of compressed content to the user. These two modules working together substantially improve server performance. So here’s the piece that’ll make you happy:
You can enable the above preset for your server by uncommenting a single line in httpd.conf:
As you can see, not so many rules are needed to adjust mod_gzip for our needs. We also showed you some examples of Helicon Ape extended syntax, but you may as well use standard Apache-compatible one. We are trying to give you a rich set of instruments, so that you can combine them the way you want and deem necessary. But simplicity and convenience are above all.