Website optimization with gzip compression in Apache2 and IIS6
The gzip compression is a simple method to reduce the caused traffic to a website and in addition to increased performance and reduce costs.
To explain how the gzip compression works, you should first know basic as a normal call (Request) and the answer (response) of a website works. Basically, it is but that's every modern Web browser that supports gzip compression in recent years. If, for example.: In your browser http://www.sysadminslife.com ansurft does the delivery of the website as follows, with and without gzip compression:
(Note: I simplified examples to quote here only in order to make clearer about that.)
HTTP request and response without gzip-compressed content:
1st The browser requests via GET request to / index.php
2nd The server looks in its web directory for the requested file
3rd The server has found the file, sends the 200 OK response code and sends the file to the browser
4th The browser now waits until the entire 100KB are transferred, and then displays the Web page
This is how the basic procedure between the browser and the server. In an HTML / PHP document, of course, quite a lot of potential savings is available if you compress the files. Thus, for example. a file that was previously only 100KB large one tenth as large (10KB) or even smaller. Moreover, it should be said that a modern website, of course, not just a html or php file retrieves, but a site several php / html files + assembles database queries.
You know now what I want out. If we compress the file to be delivered to the server before it is smaller and thus faster transfer to the browser. This of course saves time and bandwidth. The browser then invites download the zipped file from the server and extracted it before it is displayed. The delivery will look like this:
HTTP request and response with gzip-compressed content:
1st The browser requests via GET Request File / index.php to and advise that he take and handle compressed content can also
2nd The server looks in its web directory for the requested file and zips it
3rd The server has found the file, sends the response code 200 OK, tells the browser to the file is packed and sent it to the browser
4th The browser is now waiting to be transferred to 10KB, they unpacked and then displays the Web page
More precisely, consider
The browser sends request-header in that it can accept and process zipped content as well. In general, any modern Web browser sends this entry in the header: Accept-Encoding: gzip, deflate
The server sends the response headers with whether the content is delivered compressed. Content-Encoding: gzip compression at a Web server is not turned on by default. If the server does not answer mitsendet header, then the content is still transmitted without compression.
Comparison of costs and benefits of compression
Of course, the compression on the server also brings a small minus point with it. The CPU load on the server will increase by about 10% per request. In modern CPUs, the server should not be a too big problem. As can be files such as HTML, PHP, CSS, and JavaScript compress fairly well, about 70-80% of the required transfer of data is saved allowing the files to arrive more quickly at the user. The saved by the transfer time is much higher than the time needed on the server in addition to zip the content. So ultimately, but a definite yes for the extradition compressed content. You should compare the load time but still a Web page before and after the gzip configuration.
Gzip compression on Apache Server 6 configuring 2/IIS
Apache2 - Linux
In the Apache2 module deflate already included. There must be only Activates yet. For Debian or Ubuntu by running:
a2enmod deflate
Now can be activated following entry in the Apache configuration, the gzip compression. Either you use the code in your vHosts (for individual web pages) or you set it globally in your Apache config (for all websites). The MIME type should be used to select any for themselves. Of course, an execution within one. Htaccess file for specific directories and web pages possible.
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/php text/css text/js text/javascript text/javascript-x
</IfModule>
Once the module is activated and the corresponding website is configured, the Apache server to be restarted:
apache2ctl restart
detailed instructions for the advanced configuration can be found here
IIS6 - Windows
In the IIS Manager to "SERVERNAME (local computer, double-click)" and with the right mouse button on "Web Sites" and "Properties".
Now switch to the "Service" tab and you see the point already "HTTP compression. Depending on whether you want to compress dynamic content you can "Compress application files tick. "Compress static files" must be checked in any case.
Additionally you can now specify a temporary directory where the zipped file, cached. Just click on "Browse" and select a folder on a drive with enough space.
A space limit for the cached content can also be defined. I rate but with enough space on "Unlimited" position.
detailed instructions for the advanced configuration can be found here
Test whether the gzip compression works
Here there is a small tool to test whether your site delivers gzip-compressed content
Conclusion
For a website operator, it is absolutely important a site is as low as possible to keep the loading times, since one assumes that every second, one side longer required to charge users to jump a few. As an ordinary server is possible to significantly reduce the loading time, you should use the gzip compression. In addition, you can save more money because the amount left traffic is also reduced drastically. I personally have only made good experiences with it, but I am always open to criticism or other opinions about gzip compression. Let's Discuss ...
Similar items:
8 Comments on Website Optimization with gzip compression in Apache2 and IIS6
Leave a Reply
Last articles
Translator

News recommendations
- Apple buys specialist cards ( futurezone.ORF.at )
- Analyst: iPhone-4-recall would cost 1.5 billion dollars ( macnews.de )
- Picasa: Google launches online image editing ( futurezone.ORF.at )
- Vimeo Creative Commons licenses ( futurezone.ORF.at )
- Wine 1.2 takes final hurdle ( Linux Magazine Online News )






[...] Has reached. Further, one can reduce the Web server itself, the amount of data to be transmitted by compression, which of course also reduce journey times [...]
Thank you for this love of documentation generated with
Hi,
the guide is really great ... Did it just put on my web server. Funktzt super
Thanks for the well-researched information. I will ask my web host also enable gzip compression.
Encountered by chance on it and then something like useful!
I will try the same at home times.
Merci for the good guide - just on my V-Server implemented - transmitting perfectly!
Thank you for the article, exactly what I'm looking for!
Super. The tip from Google led me to it as time to tick by - and such simple then