Вы находитесь на странице: 1из 11

HTTP Compression

2015-01-16 04:54:11 UTC


2015 Citrix Systems, Inc. All rights reserved. Terms of Use | Trademarks | Privacy Statement

Contents

HTTP Compression............................................................................................

Configuring HTTP Compression ................................................................

Built-in HTTP Compression Policies ...........................................................

11

HTTP Compression
The NetScaler ADC can apply GZIP or DEFLATE algorithms to compress the HTTP responses
sent from your servers to client browsers that support compression. Compressed responses
use less bandwidth and improve website performance. The compressed responses can
include both static and dynamically generated data.
Compression is a policy based feature that supports both classic and advanced policies. You
enable the feature globally or at the service level, and bind a compression policy globally or
to a virtual server. The policy specifies the type of traffic to compress.
To configure compression, you must have a basic understanding of NetScaler policies. For
more information about policies, see "Policies and Expressions."

Configuring HTTP Compression


Compression, by default, is disabled on the NetScaler ADC. You must enable the feature
before configuring it.
You can enable compression globally or at service level. If you enable compression globally,
it is enabled for all services, regardless of whether you enable it at the service level.
For either global or service level compression, select or configure a compression policy that
specifies the type of traffic on which to perform compression, and the type of compression
(GZIP and/or DEFALTE) to apply.
The NetScaler ADC provides some built-in actions and built-in policies for compression. You
can use these built-in actions and policies or create new ones.
Note: The selected compression action is performed only if supported by the browser.
Next, you must specify the point at which the compression policy will be evaluated. To do
so, bind the policy either globally or to a load balancing or content switching virtual server.
Note: When you bind a policy to a virtual server, the policy is evaluated only by
compression-enabled services that are bound to this virtual server.

To configure compression by using the command line


interface
At the command prompt, do the following:
1. Enable compression on NetScaler.

At global level
enable ns feature cmp

At service level
set service <name> -CMP YES

Note: Compression can be enabled only for HTTP and SSL services.
2. [Optional] 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.
3. Create a compression action to specify the type of compression to be performed on the
HTTP response.

Configuring HTTP Compression


add cmp action <name> <cmpType> [-addVaryHeader <addVaryHeader>
-varyHeaderValue <string>]
4. Create a compression policy to specify the condition on which the action will be
performed.
add cmp policy <name> -rule <expression> -resAction <string>
5. Bind a compression policy to specify the point at which the policy will be evaluated.

At global level
bind cmp global <policyName> [-priority <positive_integer>] [-state
(ENABLED|DISABLED)]...
At virtual server

bind lb vserver <vserverName> -policyName <policyName> -priority


<positive_integer>
You can view the run-time statistics by using the following command:
stat cmp -detail

Configuring HTTP Compression

To configure compression by using the configuration


utility
1. Enable compression on NetScaler.

At global level
Navigate to System > Settings, click Configure Basic Features, and select HTTP
Compression.

At service level

Navigate to Traffic Management > Load Balancing > Services, select the service and
in the Settings group, enable Compression.
2. [Optional] Configure compression parameters that apply globally.
Navigate to Optimization > HTTP Compression, click Change Compression Settings and
set the relevant parameters.
3. Create a compression action to specify the type of compression to be performed on the
HTTP response.
Navigate to Optimization > HTTP Compression > Actions, click Add, and create a
compression action.
4. Create a compression policy to specify the condition on which the action will be
performed.
Navigate to Optimization > HTTP Compression > Policies, click Add and create a
compression policy by specifying the condition and the corresponding action to be
executed.
5. Bind a compression policy to specify the point at which the policy will be evaluated.

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. Navigate to Traffic Management > Load Balancing > Virtual
Servers, select the required virtual server and click Policies to bind the relevant
policy.

For content switching. Navigate to Traffic Management > Content Switching >
Virtual Servers, select the required virtual server and click Policies to bind the
relevant policy.
To view run-time statistics, navigate to Optimization > HTTP Compression, click Statistics.

Configuring HTTP Compression

Parameter Descriptions (of commands listed in the


CLI procedure)
enable ns feature
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top

set service
name
Name of the service for which to modify parameters.
CMP
Enable compression for the service.
Possible values: YES, NO
View description(s) in command reference Top

set cmp parameter


cmpLevel
Specify a compression level. Available settings function as follows:
* Optimal - Corresponds to a gzip GZIP level of 5-7.
* Best speed - Corresponds to a gzip level of 1.
* Best compression - Corresponds to a gzip level of 9.
Possible values: optimal, bestspeed, bestcompression
Default value: NSCMPLVL_OPTIMAL
quantumSize
Minimum quantum of data to be filled before compression begins.
Default value: 57344
Minimum value: 8
Maximum value: 63488
addVaryHeader
Control insertion of the Vary header in HTTP responses compressed by NetScaler.
Intermediate caches store different versions of the response for different values of the
7

Configuring HTTP Compression


headers present in the Vary response header.
Possible values: ENABLED, DISABLED
Default value: DISABLED
View description(s) in command reference Top

add cmp action


name
Name of the compression action. Must begin with an ASCII alphabetic or underscore (_)
character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.),
space, colon (:), at (@), equals (=), and hyphen (-) characters. Can be changed after the
action is added.
The following requirement applies only to the NetScaler CLI:
If the name includes one or more spaces, enclose the name in double or single quotation
marks (for example, "my cmp action" or 'my cmp action').
cmpType
Type of compression performed by this action.
Available settings function as follows:
* COMPRESS - Apply GZIP or DEFLATE compression to the response, depending on the
request header. Prefer GZIP.
* GZIP - Apply GZIP compression.
* DEFLATE - Apply DEFLATE compression.
* NOCOMPRESS - Do not compress the response if the request matches a policy that uses
this action.
Possible values: compress, gzip, deflate, nocompress
addVaryHeader
Control insertion of the Vary header in HTTP responses compressed by NetScaler.
Intermediate caches store different versions of the response for different values of the
headers present in the Vary response header.
Possible values: GLOBAL, DISABLED, ENABLED
Default value: CMP_VARY_HDR_GLOBAL
View description(s) in command reference Top

Configuring HTTP Compression

add cmp policy


name
Name of the HTTP compression policy. Must begin with an ASCII alphabetic or underscore
(_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period
(.), space, colon (:), at (@), equals (=), and hyphen (-) characters.
Can be changed after the policy is created.
The following requirement applies only to the NetScaler CLI:
If the name includes one or more spaces, enclose the name in double or single quotation
marks (for example, "my cmp policy" or 'my cmp policy').
rule
Expression that determines which HTTP requests or responses match the compression
policy. Can be a classic expression or a default-syntax expression.
Note:
Maximum length of a string literal in the expression is 255 characters. A longer string can
be split into smaller strings of up to 255 characters each, and the smaller strings
concatenated with the + operator. For example, you can create a 500-character string as
follows: '"<string of 255 characters>" + "<string of 245 characters>"'
The following requirements apply only to the NetScaler CLI:
* If the expression includes one or more spaces, enclose the entire expression in double
quotation marks.
* If the expression itself includes double quotation marks, escape the quotations by using
the \ character.
* Alternatively, you can use single quotation marks to enclose the rule, in which case you
do not have to escape the double quotation marks.
resAction
The built-in or user-defined compression action to apply to the response when the policy
matches a request or response.
View description(s) in command reference Top

bind cmp global


policyName
Name of the policy to bind globally.
View description(s) in command reference Top

Configuring HTTP Compression

bind lb vserver
policyName
Name of the policy to bind to the virtual server.
View description(s) in command reference Top

stat cmp
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top

10

Built-in HTTP Compression Policies


The following table describes the built-in HTTP compression policies. These policies are
activated globally when you enable compression.
Table 1. Built-in Classic and Advanced Policies for HTTP Compression

11

Built-in Classic and


Advanced HTTP
Compression Policies

Policy
Type

Description

ns_cmp_content_type

Classic

ns_adv_cmp_content_t
ype

Advanc
ed

Compresses data when the response contains the


header 'Content-Type' and contains text.

ns_cmp_msapp

Classic

ns_adv_cmp_msapp

Advanc
ed

ns_cmp_mscss

Classic

ns_adv_cmp_mscss

Advanc
ed

ns_nocmp_mozilla_47

Classic

ns_adv_nocmp_mozilla
_47

Advanc
ed

ns_nocmp_xml_ie

Classic

ns_adv_nocmp_xml_ie

Advanc
ed

Compresses files that are generated by the following


applications:

Microsoft Office Word

Microsoft Office Excel

Microsoft Office PowerPoint

Compresses CSS files when the request is sent from a


Microsoft Internet Explorer Web browser.

Does not compress CSS files when a request is sent


from a Mozilla 4.7 Web browser.

Does not compress when the request is sent from a


Microsoft Internet Explorer browser with a response
header 'Content-Type' and contains text or xml.

Вам также может понравиться