HTTP compression
| Functionality | Description |
|---|---|
| Compression Ratio | Compression ratio depends on the types of files in the responses, but is always significant, noticeably reducing the amount of data transmitted over the network. |
| Browser Awareness | NetScaler serves compressed data to compression aware browsers only, reducing the transaction time between the client and the server. Most modern web browsers support HTTP compression. |
| Compression blocking | You can define content filters to selectively block compression by applying built-in actions. |
| Compression Caching | With the integrated caching feature enabled, subsequent requests for the same content are served from the local cache, reducing the number of round trips to the server and improving transaction times. |
| HTTPS Support | Compression is useful on SSL connections, because it reduces the amount of content that has to be encrypted, either on the server or by the NetScaler appliance, and decrypted by the client. |
| Intelligent Response Filtering | The NetScaler compression engine intelligently filters server responses based on defined compression parameters. For example, the compression engine detects zero-content-length responses and compressed responses and does not compress them. The detection of compressed responses enables origin sites to use server-based compression with the NetScaler compression feature. |
| Compression Switching | The NetScaler appliance transparently directs requests from compression aware clients to compression capable servers, so that responses to those clients are compressed, and responses to other clients are not delayed by compression processing. |
| Heal the BREACH | NetScaler now supports Heal the BREACH (HTB) technique to mitigate the BREACH attack in its HTTP compression feature. |
How HTTP compression works
-
Static files are compressed only once, and a compressed copy is stored in local memory. Subsequent client requests for cached files are serviced from that memory.
-
Dynamic pages are dynamically created each time a client requests them.
-
The client request arrives at the NetScaler. The ADC examines the headers and stores information about what kind of compression, if any, the browser supports.
-
The ADC forwards the request to the server and receives the response.
-
The NetScaler compression engine examines the server response for compressibility by matching it against policies.
-
If the response matches a policy associated with a compression action, and the client browser supports a compression algorithm specified by the action, the NetScaler applies the algorithm and sends the compressed response to the client browser.
-
The client applies the supported compression algorithm to decompress the response.
Configure HTTP compression
-
enable ns feature cmpOR -
set service \<name\> -CMP YES
-
To enable compression globally, navigate to System > Settings > Configure Basic Features, and select HTTP Compression.
-
To enable compression for a specific service, navigate to Traffic Management > Load Balancing > Services, select the service, and click Edit.
-
In the Settings group, click the pencil icon and enable Compression.
Configure a compression action
-
Compress: Uses the GZIP algorithm to compress data from browsers that support either GZIP or both GZIP and DEFLATE. Uses the DEFLATE algorithm to compress data from browsers that support only the DEFLATE algorithm. If the browser does not support either algorithm, the browser’s response is not compressed.
-
NoCompress: Does not compress data.
-
GZIP: Uses the GNU Zip (GZIP) algorithm to compress data for browsers that support GZIP compression. If the browser does not support the GZIP algorithm, the browser’s response is not compressed.
-
Deflate: Uses the DEFLATE algorithm to compress data for browsers that support the DEFLATE algorithm. If the browser does not support the DEFLATE algorithm, the browser’s response is not compressed. After creating an action, you associate the action with one or more compression policies.
add cmp action <name> <cmpType> [-addVaryHeader <addVaryHeader> -varyHeaderValue<string>]
Configure a compression policy
| Built-in policy | Description |
|---|---|
| ns_adv_nocmp_mozilla_47 | Prevents compression of CSS files when a request is sent from a Mozilla 4.7 browser. |
| ns_adv_cmp_mscss | Compresses CSS files when the request is sent from a Microsoft Internet Explorer browser. |
| ns_adv_cmp_msapp | Compresses files that are generated by the following applications: Microsoft Office Word, Microsoft Office Excel, Microsoft Office PowerPoint. |
| ns_adv_cmp_content_type | Compresses data when the response containsContent-Type header and contains text. |
| ns_adv_nocmp_xml_ie | Prevents compression when a request is sent, from a Microsoft Internet Explorer browser and the response contains a Content-Type header and contains text or xml. |
add cmp policy <name> -rule <expression> -resAction <string>
Bind a compression policy
-
bind cmp global <policyName> [-priority <positive_integer>] [-gotoPriorityExpression <expression>] [-type <type>] [-invoke (<labelType> <labelName>) ] -
bind lb vserver <vserverName> -policyName <policyName> -type (Request|Response) -priority <positive_integer> )
-
At global level Navigate to Optimization > HTTP Compression > Policies, click Policy Manager and bind the required policies by specifying the relevant Bind Point and Connection Type (Request/Response).
-
At virtual server level
-
For load balancing virtual server, Navigate to Traffic Management > Load Balancing > Virtual Servers, select the required virtual server, click Policies, and bind the relevant policy.
-
For content switching virtual server, Navigate to Traffic Management > Content Switching > Virtual Servers, select the required virtual server, click Policies, and bind the relevant policy.
-
| Compression Parameters | Description |
|---|---|
| Quantum size | Size, in KB, of the buffer maintained for accumulating server responses. The responses are compressed when the buffer size exceeds this value. For example, if you set the quantum size to 50 KB, the NetScaler compresses the buffer's contents when its size becomes larger than 50 KB. Minimum value: 1. Maximum value: 63488. Default: 57344. |
| Compression level | Level of compression to apply to server responses. Possible values: Best Speed, Best Compression, optimal. |
| Minimum HTTP response size | Minimum size, in bytes, of an HTTP response that is compressed. Responses smaller than the value specified by this parameter are sent without being compressed. |
| Bypass compression on CPU usage | NetScaler CPU usage, as a percentage, at or above which no compression is done. Default: 100. |
| Allow Server-side compression | Allow servers to send compressed data to the NetScaler. |
| Compress push packet | Upon receipt of a packet with a TCP PUSH flag, compress the accumulated packets immediately, without waiting for the quantum buffer to be filled. |
| External Cache | Issue a private response directive indicating that the response message is intended for a single user and must not be cached by a shared or proxy cache. |
| Random GZIP Filename | Control the addition of a random file name of random length in the GZIP header to apply the HTB mitigation for the BREACH attack. Possible values: Enabled, Disabled. Default value: Disabled. |
| Minimum length of random GZIP filename | The minimum length of the random file name to be added in the GZIP header to apply the HTB mitigation for the BREACH attack. Minimum value: 8. Default: 8. |
| Maximum length of random GZIP filename | The maximum length of the random file name to be added in the GZIP header to apply the HTB mitigation for the BREACH attack. Maximum value: 63. Default: 63. |
Evaluate compression configuration
-
For more information about the statistics and charts, see the Dashboard help on the NetScaler appliance.
-
For more information about SNMP, see SNMP topic.
-
To display compression statistics summary.
stat cmp
stat cmp policy command displays statistics for Advanced policy compression policies only.
show cmp policy \<name\>
stat cmp -detail
-
Select Compression to display a summary of the compression statistics.
-
To display detailed compression statistics by protocol type, click the Details
-
To display the rate of requests processed by the compression feature, click the Graphical View tab.
-
Number of compression requests (OID: 1.3.6.1.4.1.5951.4.1.1.50.1)
-
Number of compressed bytes transmitted (OID: 1.3.6.1.4.1.5951.4.1.1.50.2)
-
Number of compressible bytes received (OID: 1.3.6.1.4.1.5951.4.1.1.50.3)
-
Number of compressible packets transmitted (OID: 1.3.6.1.4.1.5951.4.1.1.50.4)
-
Number of compressible packets received (OID: 1.3.6.1.4.1.5951.4.1.1.50.5)
-
Ratio of compressible data received and compressed data transmitted (OID: 1.3.6.1.4.1.5951.4.1.1.50.6)
-
Ratio of total data received to total data transmitted (OID: 1.3.6.1.4.1.5951.4.1.1.50.7)
-
To display HTTP compression statistics:
-
To display statistics of a compression policy.
-
To display statistics of a compression policy label
-
Navigate to Optimization > HTTP Compression > Policies > select a policy label, and click Statistics.
Offload HTTP compression
set service <service name> -CMP YES
show service <service name>
Save config
set cmp parameter –serverCmp OFF
Servercmp parameter is turned on and if the appliance receives compressed response from the server, the appliance does not further compress the data. Instead, it forwards the compressed response to the client.