Child pages
  • HTTP Compression
Skip to end of metadata
Go to start of metadata

HTTP Compression

To improve transfer speed and optimize bandwidth utilization, an HTTP server may compress data sent in response to an HTTP request. This is called HTTP compression.

The client and the server negotiate compression automatically. A client indicates its support for HTTP compression in the request. Consequently the server will know when it's safe to compress the response and what compression algorithm to use.

For example, a client that supports HTTP compression often sends the following request header:

HTTP request header
Accept-Encoding: deflate, gzip

If the server supports HTTP compression at all, invariably it will support gzip, in which case it might compress the response as indicated in the following response header:

HTTP response header
Content-Encoding: gzip

 In fact, Apache's mod_deflate module supports gzip compression (RFC 1952) only.

A historical anecdote

The use of the word "deflate" in this context is a misnomer. In the HTTP request header above, "deflate" actually refers to zlib (RFC 1950), which (like gzip) is based on deflate compression (RFC 1951). Historically, this unfortunate choice of words has resulted in incompatibilities, which is why you won't find a server that supports "deflate." This is explained in more detail on the ZLIB FAQ page.

As it turns out, SAML metadata is highly compressible, as illustrated below:

Illustrating HTTP compression with curl
$ url=http://md.incommon.org/InCommon/InCommon-metadata.xml

$ curl --verbose $url > /dev/null
*   Trying 207.75.165.125...
* Connected to md.incommon.org (207.75.165.125) port 80 (#0)
> GET /InCommon/InCommon-metadata.xml HTTP/1.1
> Host: md.incommon.org
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 12 May 2017 06:15:29 GMT
< Server: Apache
< Last-Modified: Thu, 11 May 2017 19:20:24 GMT
< ETag: "2a03576-54f447b0aaa5b"
< Accept-Ranges: bytes
< Content-Length: 44053878
< Content-Type: application/samlmetadata+xml
< 
* Connection #0 to host md.incommon.org left intact

$ curl --verbose --compressed $url > /dev/null
*   Trying 207.75.165.125...
* Connected to md.incommon.org (207.75.165.125) port 80 (#0)
> GET /InCommon/InCommon-metadata.xml HTTP/1.1
> Host: md.incommon.org
> User-Agent: curl/7.43.0
> Accept: */*
> Accept-Encoding: deflate, gzip
> 
< HTTP/1.1 200 OK
< Date: Fri, 12 May 2017 06:16:36 GMT
< Server: Apache
< Last-Modified: Thu, 11 May 2017 19:20:24 GMT
< ETag: "808ca7-54f447b0ac5af"
< Accept-Ranges: bytes
< Content-Length: 8424615
< Content-Encoding: gzip
< Vary: Accept-Encoding
< Content-Type: application/samlmetadata+xml
< 
* Connection #0 to host md.incommon.org left intact

Shibboleth supports HTTP compression out of the box, with zero configuration. If you know of other metadata client software that supports HTTP compression, please add a comment to this page.

  • No labels