ADC

Configure policies for content switching

You must create a content switching policy to identify specific types of content to be cached in one cache server or farm and identify other types of content to serve from another cache server or farm. For example, you can configure a policy to determine the location for image files with .gif and .jpeg extensions.

After defining the content switching policy, you bind it to a cache redirection virtual server and specify a load balancing virtual server. Requests that match the policy are forwarded to the named load balancing virtual server. Requests that do not match the content switching policy are forwarded to the default load balancing virtual server for the cache.

For more details about the content switching feature and configuring content switching policies, see Content switching.

You must first create the content switching policy and then bind it to the cache redirection virtual server.

Create a content switching policy by using the CLI

At the command line, type:

-  add cs policy <policyName> [-url <string> | -rule <expression>]
-  show cs policy [<policyName>]
<!--NeedCopy-->

Examples:

> add cs policy Policy-CS-JPEG -rule "REQ.HTTP.URL == '/*.jpeg'"
 Done
> show cs policy Policy-CS-JPEG
         Rule: REQ.HTTP.URL == '/*.jpeg'         Policy: Policy-CS-JPEG
         Hits: 0
 Done
>

> add cs policy Policy-CS-GIF -rule "REQ.HTTP.URL == '/ *.gif'"
 Done
> show cs policy Policy-CS-GIF
         Rule: REQ.HTTP.URL == '/ *.gif'         Policy: Policy-CS-GIF
         Hits: 0
 Done
>

> add cs policy Policy-CS-JPEG-URL -url /*.jpg
 Done
> show cs policy Policy-CS-JPEG-URL
         URL: /*.jpg     Policy: Policy-CS-JPEG-URL
         Hits: 0
 Done
>

> add cs policy Policy-CS-GIF-URL -url /*.gif
 Done
> show cs policy Policy-CS-GIF-URL
         URL: /*.gif     Policy: Policy-CS-GIF-URL
         Hits: 0
 Done
<!--NeedCopy-->

Create a URL-based content switching policy by using the GUI

  1. Navigate to Traffic Management > Content Switching > Policies.
  2. In the details pane, click Add.
  3. In Create Content Switching Policy, enter a name for the policy.
  4. Select the URL radio button.
  5. In Value, type the string value (for example, /sports).
  6. Click Create and then click Close. The policy you created appears in the Content Switching Policies page.

Create a rule-based content switching policy by using the GUI

  1. Navigate to Traffic Management > Content Switching > Policies.
  2. In the details pane, click Add.
  3. In the Create Content Switching Policy dialog box, in the Name text box, type a name for the policy.
  4. Click Add in the Action tab to create a content switch action. Or select the available action from the drop-down list.
    • Type a name for the content switch action in the Name tab.
    • Choose the virtual server or Expression from the drop-down list:
      • Loadbalancing Virtual Server
      • Global Server Loadbalancing Virtual Server
      • Authentication Virtual Server
      • NetScalar Gateway Virtual Server
      • Expression
    • Click Add or Edit to configure the Target Load Balancing Virtual Server.
  5. Click Add in the Log Action tab to create an audit message action. Or select the available audit message action from the drop-down list.
  6. In the Expression area, select the required type of expression.
  7. In the Expression Editor dialog box, choose the expression syntax that you want to use.

    In the Expression area click Evaluate to evaluate an expression evaluator. The evaluator evaluates the expression that you entered, to verify that it is valid, and displays an analysis of the expression’s effect in the Result area.

  8. Enter your policy expressions.

    For information about using the advanced syntax, see Configure advanced policy expression: Get started.

  9. Click Create and click Close. The policy you created appears in the Content Switching Policies pane.

Bind the content switching policy to a cache redirection virtual server by using the CLI

At the command prompt, type the following commands to bind the content switching policy to a cache redirection virtual server and verify the configuration:

-  bind cs vserver <name> <targetVserver> [-policyName <string>]
-  show cs vserver [<name>]
<!--NeedCopy-->

Example:

> bind cs vserver Vserver-CR-1 lbcachejpeg -policyName Policy-CS-JPEG
 Done
> bind cs vserver Vserver-CR-1 lbcachegif -policyName Policy-CS-GIF
 Done
> show cs vserver Vserver-CR-1
        Vserver-CR-1 (10.102.29.60:80) - HTTP   Type: CONTENT
        State: UP
        Last state change was at Fri Jul  2 12:53:45 2010
        Time since last state change: 0 days, 00:00:58.920
        Client Idle Timeout: 180 sec
        Down state flush: ENABLED
        Disable Primary Vserver On Down : DISABLED
        Port Rewrite : DISABLED
        State Update: DISABLED
        Default:        Content Precedence: RULE
        Cacheable: YES
        Vserver IP and Port insertion: OFF
        Case Sensitivity: ON
        Push: DISABLED  Push VServer:
        Push Label Rule: none

1)      Policy: Policy-CS-JPEG  Target: lbcachejpeg     Priority: 0     Hits: 0
2)      Policy: Policy-CS-GIF   Target: lbcachegif      Priority: 0     Hits: 0
 Done
>
<!--NeedCopy-->

Bind the content switching policy to a cache redirection virtual server by using the GUI

  1. Navigate to Traffic Management > Content Switching > Virtual Servers.

  2. In the details pane, select the virtual server for which you want to bind the policy (for example, Vserver-CS-1), and then click Open.
  3. In the Configure Virtual Server (Content Switching) dialog box, on the Policies tab, click CSW, and then click Insert Policy.
  4. In the Policy Name column, select the policy that you want to configure for the content switching virtual server.
  5. In the Target column, click the green arrow, and select the target load balancing virtual server from the list.
  6. Click OK.