¤ HTTP Gzip Compression
HTTP Gzip Compression...
This feature is available in Abyss Web Server version 2.6 (use this tutorial for versions prior). The technique I'm about to show you will allow you to increase the speed of your web pages by using the Gzip Content Compression. Enjoy!

Read the following guide and you will have a Gzip Compressed website within just a few minutes.

Return to the Hacks page

Let's get to the Hacking...
How does the "HTTP Gzip Compression" work?

The Web Server will send compressed data, and have the browser decompress this data on the fly, thus reducing the amount of data sent and increasing the page display speed. Some older browsers do not support this, but newer ones do. Don't worry, if the old browser does not support Gzip, the server will send the original uncompressed data.

I'm interested, how do I use HTTP Gzip Compression?

Make sure you correctly installed PHP before you begin. This will not be possible without PHP installed. PHP Tutorial (Windows), or you can use AbyssUnderground's tutorial. Aprelium also provides a tutorial for use with their Pre-Configured PHP package. (Recommended)

Note: Aprelium's PHP Tutorial, shows you how to install PHP for Windows, Linux, Mac OS X, and FreeBSD. I recommend this to the non-Windows folks.


First, you need to download the gzip.php file and save it to your PHP root folder. Now you must open your php.ini Configuration file and edit line #492, "auto_prepend_file" option. Here's a short example: auto_prepend_file = "C:\PHP\gzip.php". You may save your settings.

You currently only have Gzip Content Compression for your PHP files. If you wish to add Gzip to your HTML files, add "htm" and "html" as an Associated Extension in your PHP settings, which can be located in your Abyss Web Server console, under "Scripting Parameters".

How do I compress my CSS/JavaScript files?

Compressing your ".css" and ".js" files will take a little bit more work, but I have a quick and easy solution. Instead of using the external CSS/JavaScript HTML, you can use internal CSS/JavaScript HTML the same way, but the only difference is that you get it compressed.

The following code examples for CSS/JavaScript will be used in your HTML. Make sure you replace the path to your ".css" or ".js" file. For full paths to the file, use forward slashes. These
code examples assume your file is in your htdocs folder.

CSS Code:
Insert the following code in the <HEAD> section of your HTML.

<style type="text/css">
<!--
<?php 
include("./style.css"); 
?> 
-->
</style>


JavaScript Code:
Insert the following code in the <HEAD> section of your HTML.

<script language="JavaScript" type="text/javascript">
<!--
<?php 
include("./script.js"); 
?> 
-->
</script>


Note: This code needs to be placed in a file associated with PHP in order to include your CSS/JavaScript file. This code will replace the external references to your ".css" or ".js" file.

Congradulations! Your website has been successfully compressed. To test for Gzip, you can
follow this link to a Gzip testing website. I hope you enjoyed this tutorial. C ya!

Return to the Hacks page.
Copyright © 2006-2017 TRUSTAbyss.com
All Rights Reserved.