Home arrow Design Usability arrow Configuring Gzip Components
DESIGN USABILITY

Configuring Gzip Components


In this second part of a three-part series on reducing the size of the HTTP response with gzip encoding, you will learn how to configure gzip and how to handle proxy caching. This article is excerpted from chapter four of the book High Performance Web Sites: Essential Knowledge for Frontend Engineers, written by Steve Sounders (O'Reilly; ISBN: 0596529309). Copyright 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
January 12, 2011
TABLE OF CONTENTS:
  1. · Configuring Gzip Components
  2. · Proxy Caching

print this article
SEARCH DEVARTICLES

Configuring Gzip Components
(Page 1 of 2 )

Configuration

The module used for configuring gzip depends on your version of Apache: Apache 1.3 uses mod_gzipwhile Apache 2.x usesmod_deflate. This section describes how to configure each module, and focuses on Apache because it is the most popular web server on the Internet.

Apache 1.3: mod_gzip

Gzip compression for Apache 1.3 is provided by the mod_gzipmodule. There are manymod_gzipconfiguration directives, and these are described on themod_gzipweb site (http://www.schroepl.net/projekte/mod_gzip). Here are the most commonly used directives:

mod_gzip_on
   
Enables mod_gzip.

mod_gzip_item_include
mod_gzip_item_exclude

        Define which requests to gzip or not to gzip 
        based on file type, MIME type, user agent, etc.

Most web hosting services havemod_gzipturned on fortext/html by default. The most important configuration change you should make is to explicitly compress scripts and stylesheets. You can do this using the following Apache 1.3 directives:

 

mod_gzip_item_include

file

\.js$

mod_gzip_item_include

mime

^application/x-javascript$

mod_gzip_item_include

file

\.css$

mod_gzip_item_include

mime

^text/css$

 

The gzip command-line utility offers an option that controls the degree of compression, trading off CPU usage for size reduction, but there is no configuration directive to control the compression level inmod_gzip. If the CPU load caused by streaming compression is an issue, consider caching the compressed responses, either on disk or in memory. Compressing your responses and updating the cache manually adds to your maintenance work and can become a burden. Fortunately, there are options formod_gzipto automatically save the gzipped content to disk and update that gzipped content when the source changes. Use themod_gzip_can_negotiateand
mod_ gzip_update_staticdirectives to do this.

 

Apache 2.x: mod_deflate

Compression in Apache 2.x is done with the mod_deflatemodule. Despite the name of the module, it does compression using gzip. The basic configuration shown in the previous section for compressing scripts and stylesheets is done in one line:

  AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

Unlikemod_gzip,mod_deflatecontains a directive for controlling the level of compression:DeflateCompressionLevel. For more configuration information, see the Apache 2.0mod_deflatedocumentation at http://httpd.apache.org/docs/2.0/mod/mod_ deflate.html.


blog comments powered by Disqus
DESIGN USABILITY ARTICLES

- Responsive Web Design: More Than Just a Buzz...
- Add New Website Features to Please Users
- Gzip Components in Action
- Configuring Gzip Components
- Gzip Components
- Create Great JavaScript and CSS Menus Simply
- Design Principles that Shape a Web Site
- Creating Aqua Style Images
- Easy as A,B,C dynamic A to Z indexes
- EasyChart: a Usability Teaching Tool to Demo...
- Building Friendly Pop-up Windows
- Back to School: Design Usability
- Using HTML_QuickForm To Manage Web Forms, Pa...
- Using HTML_QuickForm To Manage Web Forms, Pa...
- More Website Knick Knack

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials