Skip to content

cmp policy

The following operations can be performed on "cmp policy":

add | rm | set | show | stat | rename

add cmp policy

Creates a classic or default syntax HTTP compression policy. When the policy matches an HTTP request or response, the action specified in the policy is performed on the transaction. The policy can be bound globally or to an entity. For the policy to have an effect, compression must be enabled on the service.

Synopsys

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

Arguments

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.

Example

Example 1:add cmp policy pdf_cmp -rule "RES.HTTP.HEADER Content-Type CONTAINS application/pdf" -resAction COMPRESSAfter creating the above compression policy, you must activate it by binding it globally:bind cmp global pdf_cmpThe NetScaler system will use the configured pdf_cmp compression policy to perform compression of pdf files.Example 2:The following command disables compression for all the access from the specific subnet.add cmp policy local_sub_nocmp -rule "SOURCEIP == 10.1.1.0 -netmask 255.255.255.0" -resAction NOCOMPRESSbind cmp global local_sub_nocmp

rm cmp policy

Removes a user-defined HTTP compression policy.

Synopsys

rm cmp policy <name>

Arguments

name

Name of the HTTP compression policy to be removed.

Example

rm cmp policy cmp_policy_nameThe "show cmp policy" command shows all currently defined HTTP compression policies.

set cmp policy

Modifies the specified parameters of an HTTP compression policy. Note: Use the show cmp policy command to view all configured HTTP compression policies.

Synopsys

set cmp policy <name> [-rule <expression>] [-resAction <string>]

Arguments

name

Name of the HTTP compression policy to be modified.

rule

New rule to be associated with the HTTP compression policy. You can modify the existing rule or create a new rule.

resAction

The built-in or user-defined compression action to be associated with the policy.

Example

Example 1:add cmp policy pdf_cmp -rule "RES.HTTP.HEADER Content-Type CONTAINS application/pdf" -resAction COMPRESSAfter creating the above compression policy, you must activate it by binding it globally:bind cmp global pdf_cmpThe NetScaler system will use the configured pdf_cmp compression policy to perform compression for pdf files.To disable pdf compression for Internet Explorer, you can change the above compression policy by issuing the following command:set cmp policy pdf_cmp -rule "RES.HTTP.HEADER Content-Type CONTAINS application/pdf && RES.HTTP.HEADER User-Agent NOTCONTAINS MSIE"To view the changed cmp policy, enter the following command:>show cmp policy pdf_cmp Name: pdf_cmp Rule: (RES.HTTP.HEADER Content-Type CONTAINS application/pdf && REQ.HTTP.HEADER User-Agent NOTCONTAINS MSIE) Response action: COMPRESS Hits: 2 Bytes In:...609284 Bytes Out:... 443998 Bandwidth saving...27.13% Ratio 1.37:1 Done

show cmp policy

Displays details of all HTTP compression policies.

Synopsys

show cmp policy [<name>]show cmp policy stats - alias for 'stat cmp policy'

Arguments

name

Name of the HTTP compression policy for which to display details.

Outputs

stateflag

expressionType

Type of policy (Classic/Advanced)

rule

The request/response rule that will trigger the specified compression action.

reqAction

The compression action to be performed on requests.

resAction

The compression action to be performed on responses.

hits

Number of hits.

txbytes

Number of bytes transferred.

rxbytes

Number of bytes received.

clientTTLB

Total client TTLB value.

clientTransactions

Number of client transactions.

serverTTLB

Total server TTLB value.

serverTransactions

Number of server transactions.

piHits

Number of hits.

piTxBytes

Number of bytes transferred.

piRxBytes

Number of bytes received.

piCltTTLB

Total client TTLB value.

piCltTransactions

Number of client transactions.

piSvrTTLB

Total server TTLB value.

piSvrTransactions

Number of server transactions.

boundTo

The name of the entity to which the policy is bound.

activePolicy

priority

gotoPriorityExpression

Expression specifying the priority of the next policy which will get evaluated if the current policy rule evaluates to TRUE.

labelType

Type of policy label invocation.

labelName

Name of the label to invoke if the current policy rule evaluates to TRUE.

description

Description of the policy

bindPolicyType

policyType

vserverType

builtin

Flag to determine if compression policy is builtin or not

isDefault

A value of true is returned if it is a default policy

devno

count

Example

> show cmp policy 4 Compression policies:1) Name: ns_cmp_content_type Rule: ns_content_type Response action: COMPRESS Hits: 1 Bytes In:...4325 Bytes Out:... 1530 Bandwidth saving...64.62% Ratio 2.83:12) Name: ns_cmp_msapp Rule: (ns_msie && ns_msword || (ns_msexcel || ns_msppt)) Response action: COMPRESS Hits: 7 Bytes In:...796160 Bytes Out:... 197730 Bandwidth saving...75.16% Ratio 4.03:13) Name: ns_cmp_mscss Rule: (ns_msie && ns_css) Response action: COMPRESS Hits: 04) Name: ns_nocmp_mozilla_47 Rule: (ns_mozilla_47 && ns_css) Response action: NOCOMPRESS Hits: 0 DoneYou can also view an individual cmp policy by giving the cmp policy name as an argument:> show cmp policy ns_cmp_msapp Name: ns_cmp_msapp Rule: (ns_msie && ns_msword || (ns_msexcel || ns_msppt)) Response action: COMPRESS Hits: 7 Bytes In:...796160 Bytes Out:... 197730 Bandwidth saving...75.16% Ratio 4.03:1 Done

stat cmp policy

Displays compression statistics for all advanced compression policies, or for only the specified policy.

Synopsys

stat cmp policy [<name>] [-detail] [-fullValues] [-ntimes <positive_integer>] [-logFile <input_filename>] [-clearstats ( basic | full )]

Arguments

name

Name of the advanced compression policy for which to display statistics. If no name is specified, statistics for all advanced compression polices are shown.

detail

Specifies detailed output (including more statistics). The output can be quite voluminous. Without this argument, the output will show only a summary.

fullValues

Specifies that numbers and strings should be displayed in their full form. Without this option, long strings are shortened and large numbers are abbreviated

ntimes

The number of times, in intervals of seven seconds, the statistics should be displayed.

Default value: 1

Minimum value: 0

logFile

The name of the log file to be used as input.

clearstats

Clear the statsistics / counters

Possible values: basic, full

Outputs

count

devno

stateflag

Outputs

Policy hits (Hits)

Number of hits on the policy

Policy undef hits (Undefhits)

Number of undef hits on the policy

Example

stat cmp policy

rename cmp policy

Renames a compression policy.

Synopsys

rename cmp policy <name>@ <newName>@

Arguments

name

Existing name of the policy.

newName

New name for the 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.

Choose a name that reflects the function that the policy performs.

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').

Example

rename cmp policy oldname newname

Was this article helpful?