Product Documentation

Configuring HTTP Compression

Sep 01, 2016

By default, compression is disabled on the NetScaler ADC. You must enable the feature before configuring it. If the feature is enabled, the ADC compresses server requests specified by compression policies.

To configure HTTP compression, do the following:

Enabling HTTP Compression

Compression can be enabled for HTTP and SSL services only. You can enable it globally, so that it applies to all HTTP and SSL services, or you can enable it just for specific services.

To enable compression by using the command line interface

At the command prompt, enter one of the following commands to enable compression globally or for a specific service:

  • enable ns feature cmp
    OR
  • set service <name> -CMP YES

To configure compression by using the configuration utility

Do one of the following:

  • To enable compression globally, navigate to System > Settings, click 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.

Configuring a Compression Action

A compression action specifies the action to take when a request or response matches the rule (expression) in the policy with which the action is associated. For example, you can configure a compression policy that identifies requests that will be sent to a particular server, and associate the policy with an action that compresses the server's response.

There are four built-in compression actions:

  • 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 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.

To create a compression action by using the command line interface

At the command prompt, enter the following command to create a compression action:

add cmp action <name> <cmpType> [-addVaryHeader <addVaryHeader> -varyHeaderValue <string>]

To create a compression action by using the configuration utility

Navigate to Optimization > HTTP Compression > Actions , click Add , and create a compression action to specify the type of compression to be performed on the HTTP response.

Configuring a Compression Policy

A compression policy contains a rule, which is a logical expression that enables the NetScaler appliance to identify the traffic that should be compressed.

When the NetScaler ADC receives an HTTP response from a server, it evaluates the built-in compression policies and any custom compression policies to determine whether to compress the response and, if so, the type of compression to apply. Priorities assigned to the policies determine the order in which the policies are matched against the requests.

The following table lists the built-in HTTP compression policies. These policies are activated globally when you enable compression.

Built-in Classic or Default Syntax Policy Description

ns_nocmp_mozilla_47

ns_adv_nocmp_mozilla_47

Prevents compression of CSS files when a request is sent from a Mozilla 4.7 browser.

ns_cmp_mscss

ns_adv_cmp_mscss

Compresses CSS files when the request is sent from a Microsoft Internet Explorer browser.

ns_cmp_msapp

ns_adv_cmp_msapp

Compresses files that are generated by the following applications:s

  • Microsoft Office Word
  • Microsoft Office Excel
  • Microsoft Office PowerPoint

ns_cmp_content_type

ns_adv_cmp_content_type

Compresses data when the response containsContent-Type header and contains text.

ns_nocmp_xml_ie

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.

To create a compression policy by using the command line interface

At the command prompt, enter the following command to create a compression policy:

add cmp policy <name> -rule <expression> -resAction <string>

To create a compression policy by using the configuration utility

Navigate to Optimization > HTTP Compression > Policies , click Add , and create a compression policy by specifying the condition and the corresponding action to be executed.

Binding a Compression Policy

To put a compression policy into effect, you must bind it either globally, so that it applies to all traffic that flows through the NetScaler ADC, or to a specific virtual server, so that the policy applies only to requests whose destination is the VIP address of that virtual server.

When you bind a policy, you assign it a priority. The priority determines the order in which the policies you define are evaluated. You can set the priority to any positive integer.

To bind a compression policy by using the command line interface

At the command prompt, enter one of the following commands to bind a compression policy globally or to a specific virtual server:

  • bind cmp global <policyName> [-priority <positive_integer>] [-state (ENABLED|DISABLED)]...
  • bind lb vserver <vserverName> -policyName <policyName> -priority <positive_integer>. Repeat this command for each virtual server to which you want to bind the compression policy.

To bind a compression policy by using the configuration utility

Do one of the following:

  • 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.

Setting the Global Compression Parameters for Optimal Performance

Many users accept the default values for the global compression parameters, but you might be able provide more effective compression by customizing these settings.

The following table describes the compression parameters that you can set on the NetScaler ADC.

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 ADC 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.

Policy Type*

Type of policies used for compression. Possible values: Classic, Default Syntax. Default: Classic.

Allow Server-side compression

Allow servers to send compressed data to the NetScaler ADC.

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.

To configure global compression parameters by using the command line interface

At the command prompt, enter the following command to configure compression parameters that apply globally:

set cmp parameter -cmpLevel <cmpLevel> -quantumSize <integer> [-addVaryHeader ( ENABLED | DISABLED ) [-varyHeaderValue <string>]]...

Note: Vary header parameters are available from NetScaler 10.5 onwards.

To configure global compression parameters by using the configuration utility

Navigate to Optimization > HTTP Compression , click Change Compression Settings , and set the relevant parameters.