10.3 HTTP Compression Configuration
This section covers enabling HTTP Data Compression functionality with default settings and configuring the advanced HTTP compression.
10.3.1 Configuration Guideline
Table 10-1 General Settings of HTTP Compression
Operation | Command |
Enable HTTP data compression | http compression{on|off} [virtual_name] |
View HTTP data compression status | show http compression settings |
Set advanced HTTP compression | http compression policy useragent <user_agent_string>
{js|css|pdf|ppt|xls|doc} http compression advanced useragent on |
Set the url-exclude compression rule | http compression policy urlexclude <vhost> <wildcard_expression> |
10.3.2 Configuration Example via CLI
Ø Step 1 Enable HTTP Compression
FortiBalancer(config)#http compression on
This command enables the HTTP Compression functionality with default settings. By default, the FortiBalancer appliance compresses the following MIME types for all the browsers:
- Text (text/plain)
- HTML (text/HTML)
- XML (text/XML)
- Step 2 Check the status of HTTP Compression
FortiBalancer(config)#show http compression settings
- Step 3 Configure advanced HTTP Compression
If you want to enable the compression of Java Script for Microsoft IE 5.5, you can enable it by specifying the following parameters:
FortiBalancer(config)#http compression policy useragent “MSIE 5.5” JS
There are other types of Web contents that are compressible such as:
- Java Scripts (application/x-javascript)
- Cascade Style Sheets (text/css, application/x-pointplus)
- PDF documents (application/pdf)
- PPT documents (application/powerpoint)
- XLS documents (application/MSExcel)
- DOC (application/MSWord)
Not all browsers are able to process the compressed forms of these MIME types. Support for the above MIME types requires detection of appropriate user agents that can deal with the compressed forms of these types, and then apply the compression functionality to only those user agents. To process variations in the handling of these MIME types by browsers, the FortiBalancer appliance provides the administrator with the capability to turn ON compression based on specific user agent and MIME types.
Note: TEXT, XML and HTML of HTTP compression are default values, so they do not need to be configured by the command “http compression policy useragent”.
Fortinet provides a tested list of browsers that can handle the compressed form of additional MIME types. The FortiBalancer appliance provides administrators with a way to enable the compression of additional MIME types for a best-known-working-set of browsers by using the following command:
FortiBalancer(config)#http compression advanced useragent on
It activates the compression of Java Script and CSS types for IE 6, IE 7, IE 8 and Mozilla 5.0 browsers.
Ø Step 4 Configure url-exclude HTTP Compression rule
FortiBalancer(config)#http compression policy urlexclude “v1” “/abc”
If the URL of a client request to the virtual service “v1” matches the string “/abc”, the textual contents in the response will not be compressed even if HTTP compression is turned on.
FortiBalancer(config)#http compression policy urlexclude “v1” “^/def”
If the URL of a client request to the virtual service “v1” starts from the string “/def”, the textual contents in the response will not be compressed even if HTTP compression is turned on.
FortiBalancer(config)#http compression policy urlexclude “v1” “ghi.txt$”
If the URL of a client request to the virtual service “v1” ends with the string “ghi.txt”, the textual contents in the response will not be compressed even if HTTP compression is turned on.
FortiBalancer(config)#http compression policy urlexclude “v1” “abc*def”
If the URL of a client request to the virtual service “v1” matches the string “abc*def”, the textual contents in the response will not be compressed even if HTTP compression is turned on.