CherryPy on IronPython and Gzip

Gzip encoding is used widely by web servers to compress the content for transfer over the internet. It is supported by almost all web browsers there are and in general, it’s always better to compress non-binary content than not to compress it.

CherryPy has gzip compression support built into it, however as you might know IronPython is missing the zlib module that is used for gzip compression. In CPython, the module is implemented in C to give better performance.

Jeff Hardy has taken ComponentAce’s zlib.net and wrapped it round in a nice IronPython module called IronPython.Zlib. This works great with the CherryPy implementation of IronPython.

If you add this .dll and add it to your search path, you should simply be able to import zlib directly from IronPython.

To enable gzip compression in CherryPy, simply add

tools.gzip.on : True

to your application configuration.

Advertisements