ADC

HTTP compression

For websites with compressible content, the HTTP compression feature implements lossless compression to alleviate latency, long download times, and other network-performance problems by compressing the HTTP responses sent from servers to compression-aware browsers. You can improve server performance by offloading the computationally intensive compression task from your servers to the Citrix ADC appliance.

The following table describes the capabilities of the HTTP compression feature:

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 Citrix ADC 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 Citrix ADC appliance, and decrypted by the client.
Intelligent Response Filtering The Citrix ADC 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 Citrix ADC compression feature.
Compression Switching The Citrix ADC 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.

How HTTP compression works

A Citrix ADC can compress both static and dynamically generated data. It applies the GZIP or the DEFLATE compression algorithm to remove extraneous and repetitive information from the server responses and represent the original information in a more compact and efficient format. This compressed data is sent to the client’s browser and uncompressed as determined by the browser’s supported algorithm or algorithms (GZIP or DEFLATE).

Citrix ADC compression treats static and dynamic content differently.

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

When a client sends a request to the server:

  1. The client request arrives at the Citrix ADC. The ADC examines the headers and stores information about what kind of compression, if any, the browser supports.
  2. The ADC forwards the request to the server and receives the response.
  3. The Citrix ADC compression engine examines the server response for compressibility by matching it against policies.
  4. If the response matches a policy associated with a compression action, and the client browser supports a compression algorithm specified by the action, the Citrix ADC applies the algorithm and sends the compressed response to the client browser.
  5. The client applies the supported compression algorithm to decompress the response.

Configure HTTP compression

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

To enable HTTP compression by using the CLI

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.

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 GUI

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.

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

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

To configure a compression policy by using the CLI

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

When the Citrix 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.

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 action by using the GUI

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 Citrix ADC appliance to identify the traffic that should be compressed.

When the Citrix 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: 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.

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 Citrix 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 CLI

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> -type (Request|Response) -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 GUI

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.

Set the Global Compression Parameters for Optimal Performance

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

Note After you configure the global compression parameters, you do not have to reboot your appliance. They get applied to the new flows immediately.

The following table describes the compression parameters that you can set on the Citrix 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 Citrix 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 Citrix ADC 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 Citrix 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 HTTP compression by using the GUI

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.

To create a compression action by using the GUI

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

To create a compression policy by using the GUI

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

Evaluate compression configuration

You can view the compression statistics in the dashboard utility or in an SNMP monitor. The dashboard utility displays summary and detailed statistics in a tabular and graphic format.

Optionally, you can also view statistics for a compression policy, including the number of requests that the policy counter increments during the policy based compression.

Note

  • For more information about the statistics and charts, see the Dashboard help on the Citrix ADC appliance.
  • For more information about SNMP, see SNMP topic.

To view compression statistics by using the CLI

At the command prompt, enter the following commands to display the compression statistics:

  1. To display compression statistics summary.

stat cmp

Note The stat cmp policy command displays statistics for default syntax compression policies only.

2. To display compression policy hits and details          show cmp policy \<name\>

3. To display detailed compression statistics          stat cmp -detail

To view compression statistics by using the dashboard:

In the Dashboard utility, you can display the following types of compression statistics:

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

To view compression statistics by using SNMP

You can view the following compression statistics by using the SNMP network management application.

  • 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 view more compression statistics by using the GUI

  1. To display HTTP compression statistics:

Navigate to OptimizationHTTP Compression and click Statistics.

  1. To display statistics of a compression policy.

Navigate to OptimizationHTTP CompressionPolicies > select the policy, and click Statistics.

  1. To display statistics of a compression policy label

  2. Navigate to OptimizationHTTP CompressionPolicies > select a policy label, and click Statistics.

Offloading HTTP compression

Performing compression on a server can affect the server’s performance. A Citrix ADC placed in front of your web servers and configured for HTTP compression offloads compression of both static and dynamic content, saving server CPU cycles and resources.

You can offload compression from the Web servers in either of two ways:

Disable compression on the web servers, enable the Citrix ADC Compression feature at a global level, and configure services for compression.

Leave the compression feature enabled on the web servers and configure the Citrix ADC appliance to remove the “Accept Encoding” header from all HTTP client requests. The servers then send uncompressed responses. The Citrix ADC compresses the server responses before sending them to the clients.

Note The second option does not work if the servers automatically compress all responses. The Citrix ADC does not attempt to compress a response that is already compressed.

The Servercmp parameter enables the Citrix ADC appliance to handle offload HTTP compression. By default, this parameter is set ON for the server to send compressed data to the Citrix ADC appliance. To offload HTTP compression, you need to set the servercmp parameter to OFF. At the command prompt, enter the following commands:

set service <service name> -CMP YES

Repeat this command for each service for which you want to enable compression.

show service <service name>

Repeat this command for each service, to verify that compression is enabled.

Save config

set cmp parameter –serverCmp OFF

Note:

When the 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.

HTTP compression