One of the main qualities of a website is fast loading. But it depends on the size of Web pages and their components. There are a number of techniques to reduce the overall size downloaded by the user.
Compressing web pages on the fly
The HTTP protocol provides a mechanism to compress web pages on the fly for the Mariners. To implement this compression, it usually takes to install a module on the server and configure it. Under the browser Apache, the module is the most used mod_gzip. Here is a sample configuration for this module:
AddEncoding gzip .gz
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0"
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.php3$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.js$
mod_gzip_item_include file \.css$
mod_gzip_item_include mime ^text/
mod_gzip_item_exclude mime ^httpd/unix-directory
mod_gzip_item_exclude mime ^image/
- Note that: It is also necessary to add mod_gzip to the list of modules installed by inserting the following line last in the list, because the Gzip compression should intervene at the end of the process:
LoadModule gzip_module /usr/lib/apache/1.3/mod_gzip.so
- Then we must reload the Apache configuration for example by running one of the following:
killall -HUP apache
/etc/init.d/apache reload > /dev/null
Test the Gzip compression
Once the new Apache configuration taken into account, you can not easily check if compression is taken into account, since the web browsers (Firefox, IE, Opera, etc..) Handle the completely transparent.
Thus, it is necessary to look at the HTTP headers exchanged between the server and browser. For this there are online tools ready for use:
Published by jak58
Latest update on June 30, 2010 at 10:43 AM by jak58.