Compression

A plugin that provides the capability to compress a response and decompress request bodies. You can use different compression algorithms, including gzip and deflate, specify the required conditions for compressing data (such as a content type or response size), or even compress data based on specific request parameters.

Note that if the request body was decompressed, the plugin will remove HttpHeaders.ContentEncoding and HttpHeaders.ContentLength headers. Also, it will add HttpHeaders.TransferEncoding header with chunked value. Original encodings can be accessed through ApplicationRequest.appliedDecoders property.

The example below shows how to compress JavaScript content using gzip with the specified priority:

install(Compression) {
gzip {
priority = 0.9
matchContentType(ContentType.Application.JavaScript)
}
}

You can learn more from Compression.