1. Problem

To save bandwidth and make pages download faster, you want to compress output before sending it to the client.

2. Solution

Quixote supports transparent compression of HTTP message bodies, though it's turned off by default. To turn it on, you can either supply a setting in the configuration file you pass to the Publisher's read_config() method:

COMPRESS_PAGES = True

Or you can use Python code to set an attribute on the publisher's configuration:

publisher.config.compress_pages = True
publisher.publish_cgi()      # Or whatever...

3. Discussion

Only gzip compression is supported. Clients will receive compressed output if they claim to support the "gzip" or "x-gzip" encoding, and if the HTTP body is larger than 200 bytes.


CategoryCookbook