Feb 042010
Turn on content compression in Apache
Answer:
By turning on content compression in Apache, content's transfer size can be reduced for users and hence a faster loading time. However, not all content types can be compressed, e.g. images, videos, we usually only compress text content types, e.g. html, xml, css & js.
Steps:
Add the following lines to the Apache configuration (httpd.conf)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml application/xml application/javascript application/json text/css text/plain
header set Vary Accept-Encoding
# Don't compress images - Important for IE caching bug
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
header unset Vary env=dont-vary
</IfModule>
Restart Apache to take effect
# apachectl -k graceful
Assume the module mod_deflate is enabled