Taking advantage of on-the-fly compression

Starting from version 2.6, Abyss Web Server offers integrated on-the-fly compression. This article focuses on this new feature and discusses different aspects of its use.

How does on-the-fly compression work?

Abyss Web Server can compress any content before sending it to whether it is static (a file on the hard disk) or dynamically generated (XSSI page or the result of a script execution). Compression helps save bandwidth consumption at some extra processing and memory overhead.

The compression is transparently negotiated between the browser and the server. So if the browser does not claim support for HTTP compression, the server will send the contents without compressing them. The server can also chose to not compress some content even though the browser understands compression. Such a choice is usually directed by the server configuration which could limit compression to some areas of the site or to some types of contents only.

Configuring on-the-fly compression

By default, Abyss Web Server is configured to compress content which MIME type belongs to the text type group. This includes HTML pages (text/html), plain text (text/plain), CSS pages (text/css), and XML files (text/xml). These kinds of files can usually achieve an average of 30% size saving when compressed.

If your site hosts other types of contents that can be well compressed, you can declare them in the console. For example, to add application/javascript to the list of MIME types concerned by the compression:

  • Open the console.
  • In the Hosts table, Press the Configure button associated with the host you would like to configure.
  • Select Compression
  • Ensure that Compression Level is set to a value different from 0 (None).
  • Press Add in the MIME Types table.
  • Enter application/javascript in MIME type.
  • Press OK.
  • Press OK one more time to leave the Compression dialog.
  • Press Restart.

Adjusting the compression level

The compression level can range from 0 (no compression) to 9 (maximum compression). It is preset to 6 which offers a good compromise between the compression ratio, the processing overhead, and the memory used to perform the compression.

Please note that in most cases, choosing levels 7, 8, or 9 does not offer a significant improvement in the compression ratio. But it comes with much higher memory consumption and requires longer processing time. So users must be aware that the extra few percents of the compression ratio with these levels can cost a lot.