Fortinet black logo

Handbook

Configuring compression rules

Configuring compression rules

To offload compression from your back-end servers, you can configure FortiADC to perform HTTP/HTTPS compression on behalf of the server.

The following content types can be compressed:

  • application/javascript
  • application/soap+xml
  • application/x-javascript
  • application/xml
  • text/css
  • text/html
  • text/javascript
  • text/plain
  • text/xml
  • custom

Not all HTTP.HTTPS responses should be compressed. Compression offers the greatest performance improvements when applied to URIs whose media types include repetitive text such as tagged HTML and JavaScript. Files that already contain efficient compression such as GIF images usually should not be compressed, as the CPU usage and time spent compressing them will result in an increased delay rather than network throughput improvement. Plain text files where no words are repeated, such as configurations with unique URLs or IPs, also may not be appropriate for compression.

FortiADC supports HTTP/HTTPS response compression in either gzip or deflate format.

Before you begin:

  • You must have a good understanding of HTTP/HTTPS compression and knowledge of the content types served from the back-end real servers.
  • You must have Read-Write permission for Load Balance settings.

Compression is not enabled by default. After you have configured a compression inclusion rule, you can select it in the profile configuration. To enable compression, select the profile when you configure the virtual server.

To configure a compression rule:
  1. Click Server Load Balance > Application Optimization.
  2. Click the Compression tab.
  3. Click Add to display the configuration editor.
  4. Complete the configuration as described in Compression configuration.
  5. Save the configuration.

Compression configuration

Settings Guidelines

Name

Configuration name. Valid characters are A-Z, a-z, 0-9, _, and -. No spaces. You reference this name in the profile configuration.

Note: After you initially save the configuration, you cannot edit the name.

URI List Type

  • Include— Select this option to create a compression inclusion rule. HTPP/HTTPS responses that match the URIs and content types specified in this rule will be compressed by FortiADC before being passed to the client.
  • Exclude—Select this option to create a compression exclusion rule. HTPP/ HTTPS responses that match the URIs and content types specified in this rule will not be compressed by FortiADC before being passed to the client.

URI Rule

Click Add and specify the URI to create the rule. Note: You must use a regular expression, e.g., https://example.com/tmp/test.txt.

Content Types

Click Add and select from the following content types to build the list:

  • application/javascript
  • application/soap+xml
  • application/x-javascript
  • application/xml
  • text/css
  • text/html
  • text/javascript
  • text/plain
  • text/xml
  • custom

Note: The "custom" option allows you to specify almost any content/media type, including image files in .JPG, .PNG, and .BMP formats. The default is */*, which means any content/media type.

You can use the CLI to configure advanced options:

config load-balance compression

edit 1

set cpu-limit {enable | disable}

set max-cpu-usage <percent> -- max cpu usage for compression

set min-content-length <bytes> -- min bytes for compression

end

Configuring compression rules

To offload compression from your back-end servers, you can configure FortiADC to perform HTTP/HTTPS compression on behalf of the server.

The following content types can be compressed:

  • application/javascript
  • application/soap+xml
  • application/x-javascript
  • application/xml
  • text/css
  • text/html
  • text/javascript
  • text/plain
  • text/xml
  • custom

Not all HTTP.HTTPS responses should be compressed. Compression offers the greatest performance improvements when applied to URIs whose media types include repetitive text such as tagged HTML and JavaScript. Files that already contain efficient compression such as GIF images usually should not be compressed, as the CPU usage and time spent compressing them will result in an increased delay rather than network throughput improvement. Plain text files where no words are repeated, such as configurations with unique URLs or IPs, also may not be appropriate for compression.

FortiADC supports HTTP/HTTPS response compression in either gzip or deflate format.

Before you begin:

  • You must have a good understanding of HTTP/HTTPS compression and knowledge of the content types served from the back-end real servers.
  • You must have Read-Write permission for Load Balance settings.

Compression is not enabled by default. After you have configured a compression inclusion rule, you can select it in the profile configuration. To enable compression, select the profile when you configure the virtual server.

To configure a compression rule:
  1. Click Server Load Balance > Application Optimization.
  2. Click the Compression tab.
  3. Click Add to display the configuration editor.
  4. Complete the configuration as described in Compression configuration.
  5. Save the configuration.

Compression configuration

Settings Guidelines

Name

Configuration name. Valid characters are A-Z, a-z, 0-9, _, and -. No spaces. You reference this name in the profile configuration.

Note: After you initially save the configuration, you cannot edit the name.

URI List Type

  • Include— Select this option to create a compression inclusion rule. HTPP/HTTPS responses that match the URIs and content types specified in this rule will be compressed by FortiADC before being passed to the client.
  • Exclude—Select this option to create a compression exclusion rule. HTPP/ HTTPS responses that match the URIs and content types specified in this rule will not be compressed by FortiADC before being passed to the client.

URI Rule

Click Add and specify the URI to create the rule. Note: You must use a regular expression, e.g., https://example.com/tmp/test.txt.

Content Types

Click Add and select from the following content types to build the list:

  • application/javascript
  • application/soap+xml
  • application/x-javascript
  • application/xml
  • text/css
  • text/html
  • text/javascript
  • text/plain
  • text/xml
  • custom

Note: The "custom" option allows you to specify almost any content/media type, including image files in .JPG, .PNG, and .BMP formats. The default is */*, which means any content/media type.

You can use the CLI to configure advanced options:

config load-balance compression

edit 1

set cpu-limit {enable | disable}

set max-cpu-usage <percent> -- max cpu usage for compression

set min-content-length <bytes> -- min bytes for compression

end