
The bandwith increase allows now a better comfort for users but also an explosion of multimedia resources. There many kinds of resources :
- images : images are always bigger;
- the "web 2.0" involves lots of CSS and Javascript scripts;
- HTML pages
For static resources as images, it's possible to take advantage of browser cache, likewise for CSS and Javascripts.
However, these last resources tend to be bigger and longer and so disturb page construction because of data transfert delays.
It's possible to speed up these delays with
httpd thanks to the
deflate mode.
To setting up the compression,
httpd must have been compiled with the
deflate and
headers modules.
./configure --prefix=/usr/local/apache2-2.2.0 --enable-headers --enable-deflate --with-mpm=prefork
make
make install
Then, put the following block in the
httpd.conf file or in a
mod_deflate.conf file which must be included
(Include mod_deflate.conf) :
<IfModule deflate_module>
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE text/*
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/x-javascript
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problemsx85
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex wonx92t work. You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
# Donx92t compress images or ZIP/GZ/7Z
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|zip|7z|gz|htc)$ no-gzip dont-vary
# Make sure proxies donx92t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
</IfModule>
Here, resources with a
type-mime as
text/*,
javascript and XML feeds (as RSS feeds) are compressed.