Bookmark Me | RSS | RSS | Comments RSS

HTTP Compression - A faster way to improve web site performance - At minimal cost

Wednesday, November 5, 2008


HTTP compression

- is a simple way to improve site performance and decrease bandwidth, with no configuration required on the client side.

- is a capability built into both web servers and web browsers, to make better use of available bandwidth.

- HTTP protocol data is compressed before it is sent from the server.

How HTTP Compression Works
When IIS receives a request, it checks whether the browser that sent the request is compression-enabled. (Recent versions of Microsoft® Internet Explorer and most other browsers typically send the following header if they are compression-enabled: Accept-Encoding: gzip, deflate.) IIS then determines whether the request is for a static file or for dynamic content.

If the content of the file is static, IIS checks whether the file has previously been requested and is already stored in a compressed format in the temporary compression directory. If a compressed version of the requested file is not found, IIS sends an uncompressed version of the requested file to the client browser while a background thread compresses the requested file. The newly compressed file is then stored in the compression directory, and subsequent requests for that file are serviced directly from the compression directory. In other words, an uncompressed version of the file is returned to the client unless a compressed version of the file already exists in the compression directory.

If the file contains dynamic content, IIS compresses the response as it is generated and sends the compressed response to the browser. No copy of the file is cached by the Web server.

The performance cost of compressing a static file is modest and is typically incurred only once, because the file is then stored in the temporary compression directory. The cost of compressing dynamically generated files is somewhat higher because the files are not cached and must be regenerated with each request. The cost of expanding the file at the browser is minimal. Compressed files download faster, which makes them particularly beneficial to the performance of any browser that uses a network connection with restricted bandwidth (a modem connection, for example).

If your Web sites use large amounts of bandwidth or if you want to use bandwidth more effectively, consider enabling HTTP compression, which provides faster transmission times between IIS and compression-enabled browsers regardless of whether your content is served from local storage or a UNC resource. If your network bandwidth is restricted, HTTP compression can be beneficial unless your processor usage is already very high.

IIS provides the following compression options:

• Static files only.

• Dynamic application responses only.

• Both static files and dynamic application responses.

Dynamic processing can affect CPU resources because IIS does not cache compressed versions of dynamic output. If compression is enabled for dynamic responses and IIS receives a request for a file that contains dynamic content, the response that IIS sends is compressed every time it is requested. Because dynamic compression consumes considerable CPU time and memory resources, use it only on servers that have slow network connections but CPU time to spare.

Compressed static responses can be cached and therefore do not affect CPU resources like dynamic responses do.

Compressing application response files is usually called dynamic compression.

Using HTTP Compression for Faster Downloads (IIS 6.0)

Enabling HTTP Compression (IIS 6.0)

Customizing the File Types IIS Compresses (IIS 6.0)

Speed Web delivery with HTTP compression



Tags: ,
Filed Under: ASP.NET

Add comment