Compress Your web Page

In this Tutorial we”ll provide you with some details on what file compression is and why it’s essential in optimizing your site.

You might have heard some talk about how compressing your web pages helps with your site’s SEO, but how does it help and how can you use it on your site? This article will provide you with some details on what file compression is and why it’s essential to the process of optimizing your site.

When you click on a link and a web page comes up in your browser, there are a few steps which take place in order for that page to become visible to you. First, your browser (internet explorer, Firefox etc) sends a request to the web server (the computer where a website’s files are stored).
If you were to image we server and browsers as human then the drama action that were to take place will be this.

“Hey web example (for ‘,’) this is Dexter (your internet browser). Dexter is asking for the home page ‘,’ please send me the file for that page.”

This is what happens outside in real world, everything is usual. But within example his brain will have to think where he has kept the file and search it for Dexter. That is what happens in the web server too. Web server searches for the file ‘,’ reading it and responding by sending that page to Dexter’s browser. Once Dexter’s browser receives the page, Dexter would be able to view the page by looking at his computer screen.

The faster these steps take place, the faster the page is loaded into Dexter’s browser and the less time Dexter has wait for that page to “load.” Web page load time is becoming more and more important to the search engines when it comes to determining how well optimized a website is. This is because sites with longer load times require users to wait longer while sites with faster load times require less waiting time. Thus allows user to find the best site.
Since web users like to get what they want quickly, this means that the faster your site loads, the more user friendly it will be and the more the search engines will like it. The problem is that the larger your web pages are, the more time it takes the web server to read the information in the file and send it over to the browser so that the page can be viewed.

This means if the page of example is very big it will take longer to load, like us Dexter too don’t like to wait for long for the page, so he moves to another web site, But with file compression like GZIP, you can reduce the size of your web page files by up to 70%, which equals faster loading time and a happier Dexter…which in the end equals better status with the search engines.

You can accomplish this by compressing the file before sending it to the user’s browser. You can do that by using Deflate or GZIPor using zlib module.

Deflate ,GZIP or zlib module

Deflate is an option which comes automatically with the Apache server and which is simple to set up. GZIP on the other hand needs to be installed and requires a bit more work to install. However, GZIP does achieve a higher compression rate and therefore might be a better choice if your website uses pages which have a lot of images or large file sizes.

On the other hand, if your site has over 1,000 unique visitors a day, deflate is actually a better selection because it requires much less energy to compress files, which means your high volume of visitors won’t slow down your site due to the increase in GZIP compression.

zlib module on the other hand does not need much installation and configuring tasks , but it should be enabled in your web server and your pages must be written in PHP.

File Compression with Deflate

Setting up file compression for your website will depend on type of server you use. Most likely, you’ll be using Apache, which means you can enable compression by adding a few codes to your .htaccess file.

This file can be found by accessing your websites control and command (CNC) panel and is located in your main directory.
Then, you simply add the codes to your .htaccess file which will compress your site’s files by types. For example, if you want to compress all of the .txt and HTML files on your site:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html

To compress your .css and javascript:

AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Other Options is

SetOutputFilter DEFLATE


File Compression with zlib module

To use compression with zlib module you server needs to have zlib module enabled.

To make sure that the version of PHP on your web server is extended with the zlib module. To find out quickly, just open a text editor and type in the following:


Then save the file as phpinfo.php and upload it to your webserver. Once you view this page on your browser, look for zlib on the web page. If it”s installed, one table on the page would look this:


On that same page, just note that the PHP version on your web server is 4.0.6 or higher otherwise you can”t use this method to compress your web pages.

Then all you need to do is to add

to compress.

Here is a sample code to compress your web pages


This web page is now COMPRESSED!

To check if the Browser header for header for “Accept-encoding” and returns the compressed or regular version of the file.

Anyway, many agree that the following facts sure

  1. speed gains are negligible,
  2. it reduces bandwidth…
  3. does not effect images (gifs / jpgs / pngs) since they”re already compressed
  4. you can (add it to and) use .htaccess to make it work on your entire website alternatively.