We Have Moved
The IBM Application Gateway has a new home - docs.verify.ibm.com/gateway
The documentation on this site will no longer be maintained after v21.02, please update your bookmarks.
The 'Accept-Encoding' HTTP request header can be used by a client to signal whether it accepts compressed responses. In addition to this the IBM Application Gateway (IAG) server can be configured to enable or disable compression of responses which are sent by the IAG server to the client based on the MIME-type and size of the response.
If the 'Accept-Encoding' header indicates that the client supports compressed responses, and the MIME-type of the response matches one of the pre-configured MIME-types, and the compression for the user agent has not been specifically disabled, the response will be compressed.
If compression is required the IAG server will use the gzip compression algorithm to perform the compression, as described in RFC 1952. This compression algorithm is supported by all major browsers.
Compression Based on MIME Type
The IAG server can be configured to disable/enable response compression for a particular MIME-type or group of MIME-types, as shown in the following YAML snippet template:
advanced: configuration: - stanza: compress-mime-types operation: set entry: <mime_type> value: - <minimum_doc_size>[:<compression_level>]
The <mime-type> can specify one particular MIME type or wildcard characters can be used to specify a class of MIME types. Order is important. The first entry that matches a returned document is used for that document. If the response does not match any configured MIME-type compression will not take place on the response.
The <minimum_doc_size> value specifies the policy on the size of the responses that are compressed. This value is an integer. Possible values include:
|< -1||Any negative number other than -1 will generate an error message.|
|-1||Documents of the specified MIME-type are never compressed.|
|0||Documents of the specified MIME-type are always compressed.|
|>0||Documents of the specified MIME-type are compressed when the number of bytes in the response exceeds this integer value.|
- When IAG receives a response from an application it will examine 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, the IAG server will compress the response unless the applicable MIME-type is configured to never be compressed.
- 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 benefits of increased compression must be weighed against any performance impacts caused by the compression algorithm. 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:
advanced: configuration: - stanza: compress-mime-types operation: set entry: "*/*" value: - 1000
The following example:
- 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.
advanced: configuration: - stanza: compress-mime-types operation: set entry: "image/*" value: - -1 - stanza: compress-mime-types operation: add entry: "text/css" value: - -1 - stanza: compress-mime-types operation: add entry: "application/pdf" value: - 0:5 - stanza: compress-mime-types operation: add entry: "text/html" value: - 2000 - stanza: compress-mime-types operation: add entry: "text/*" value: - 0
Compression Based on User Agent
IAG can be configured to disable compressed responses for specific user agents. A user agent is a client that initiates a request, as identified by the user-agent header in the HTTP request.
Examples of user agents include browsers, editors, spiders (web-traversing robots), or other tools. The IAG server does not return compressed data to user agents that do not request it. However, some user agents request compressed data but do not know how to handle the data properly.
The IAG server can be configured to explicitly disable compression for user agents, as shown in the following YAML snippet template:
advanced: configuration: - stanza: compress-user-agents operation: set entry: <user_agent_pattern> value: - <yes|no>
- The <user_agent_pattern> consists of a wildcard pattern which is matched against the user-agent header found in the HTTP request.
- A corresponding value of 'yes' means that compression is supported by the client. A corresponding value of 'no' means that compression is not supported by the client.
For example, the following YAML enables compression for Internet Explorer, but disables compression for all other clients:
advanced: configuration: - stanza: compress-user-agents operation: set entry: "*MSIE*" value: - yes - stanza: compress-user-agents operation: add entry: "*" value: - no