HTML and CSS Reference
In-Depth Information
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip
!gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
The community project
HTML5Boilerplate.com
contains an excellent example of an
optimized
.htaccess
file. It's specifically crafted for web performance optimizations. It
provides a great starting point for implementing HTTP compression properly. It also
serves as a nice guide to compare to an existing web server configuration to verify you
are
following
best
practices
You can view most other major server configurations for HTTP compression in the
github repository for HTML5Boilerplate (
https://github.com/h5bp/server-configs
)
, as
well as
Figure 4-3
. Some of the configurations included are:
• Node.js
• IIS
• Nginx
• lighttpd
• Google App Engine
After you think you have properly configured your web server from a compression and
optimization point of view, you must validate it.
Web Sniffer
is an excellent, free, web-
based tool that enables you make individual HTTP requests and see the responses. As
you can see in
Figure 4-4
, Web Sniffer gives you some control over the
userAgent
and
Accept-Encoding
headers to ensure that compressed content is delivered properly.