Compression based on MIME-type
We can create an entry in the WebSEAL configuration file for each MIME-type or group of MIME-types for which data compression is needed.
[compress-mime-types] mime_type = minimum_doc_size[:compression_level]
The mime-type can specify one particular MIME type or can use wildcard characters to specify a class of MIME types. Each mime-type declaration is a separate entry in the [compress-mime-types] stanza. The wildcard character (*) is limited to entries of one collection of MIME types. For example, text/*. Any MIME-type not listed in the stanza is not compressed. Order is important. The first entry matching a returned document is used for that document.
The minimum_doc_size value specifies the policy on the size of documents that are compressed. This value is an integer. Valid values are shown in the following list.
- -1
When the minimum size is -1, documents of the specified MIME-type are never compressed.
- 0
When the minimum size is 0, documents of the specified MIME-type are always compressed.
- Integer greater than zero
When the minimum size is greater than zero, documents of the specified MIME-type are compressed when the number of bytes in the response to WebSEAL exceeds this integer value.
Any negative number other than -1 generates an error message.
When WebSEAL receives a request from a browser, the server examines the content-length field in the HTTP header to determine the size of the incoming data. However, not all HTTP responses contain the content-length field. When the content-length field is not found, WebSEAL compresses the document unless the applicable MIME-type is configured to never be compressed. For example, minimum_doc_size of -1.
The compression_level is an optional setting that specifies the data compression level. Valid values are integers 1 - 9. The larger the integer, the greater the amount of compression that takes place. The greater the amount of compression, the greater the load that is placed on the CPU. The value of increased compression must be weighed against any performance impacts. When the compression_level is not specified, a default level of 1 is used.
The following example compresses all documents of a size greater than 1000 bytes:
[compress-mime-type] */* = 1000The following set of entries:
- disables compression for all images
- disables compression for CSS files
- enables compression at level 5 for all PDF documents
- enables compression for HTML documents of size greater than 2000 bytes
- enables compression for all other text documents, regardless of size
,
[compress-mime-type] image/* = -1 text/css = -1 application/pdf = 0:5 text/html = 2000 text/* = 0
Parent topic: HTTP data compression