Apache Compression
Views:
Apache 2 can compress text content before sending it. This gives a real speed boost, even for people with fast connection speeds. Compression is carried out by the Deflate Module.
The default settings for mod_deflate don't quite cut it with Internet Explorer. IE likes to tell web servers it's capable of doing things that it isn't.
Some additional directives need to be added to the configuration to make sure that only things IE can genuinely handle compressing are compressed.
There are also a lot of extra content types that can be compressed, which are listed in the default config. Likewise, there are plenty more files types that should never be compressed at all.
LoadModule deflate_module modules/mod_deflate.so # Insert filter AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/atom_xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript # Netscape 4.x has some problems... 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 # Don't deflate content for IE by default - only deflate text/html content BrowserMatch \bMSIE no-gzip !gzip-only-text/html msie BrowserMatch \bMSIE\s6 msie6 BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html msie7 BrowserMatch \bMSIE\s8 !no-gzip !gzip-only-text/html msie8 # Don't compress images etc SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png|zip|tgz|gz|bz|pdf|exe|doc|xls|bin|bmp|ico)$ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary
