进行gure 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, seeContent 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 command CLI
At the command line, type:
- add cs policy [-url | -rule ] - show cs policy []
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
Create a URL-based content switching policy by using the GUI
- Navigate to Traffic Management > Content Switching > Policies.
- In the details pane, click Add.
- In the Create Content Switching Policy dialog box, in the Name text box, type a name for the policy.
- Select the URL radio button.
- In the Value text box, type the string value (for example,/sports).
- Click Create and click Close. The policy you created appears in the Content Switching Policies page.
Create a rule-based content switching policy by using the GUI
Navigate to Traffic Management > Content Switching > Policies.
In the details pane, click Add.
In the Create Content Switching Policy dialog box, in the Name text box, type a name for the policy.
Select the Expression radio button, and then click Configure.
In the Create Expression dialog box, choose the expression syntax that you want to use.
- If you want to use default syntax, accept the default and proceed to the next step.
- If you want to use classic syntax, click Switch to Classic Syntax.
The Expression portion of the dialog box changes to match your choice. The default syntax Expression view has fewer elements than does the classic syntax Expression view. In the default syntax Expression view, instead of a preview window, a button provides access to an expression evaluator. The evaluator evaluates the expression you entered, to verify that it is valid, and displays an analysis of the expression’s effect.
Enter your policy expressions.
For information about using the advanced syntax, see进行gure advanced policy expression: Get started.
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:
——结合cs vserver <名称> < targetVserver > [-policyName ] - show cs vserver []
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 >
Bind the content switching policy to a cache redirection virtual server by using the GUI
- Navigate to Traffic Management > Content Switching > Virtual Servers.
- 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.
- In the Configure Virtual Server (Content Switching) dialog box, on the Policies tab, click CSW, and then click Insert Policy.
- 在政策名称列,选择政策you want to configure for the content switching virtual server.
- In the Target column, click the green arrow, and select the target load balancing virtual server from the list.
- Click OK.
In this article
- Create a content switching policy by using the command CLI
- Create a URL-based content switching policy by using the GUI
- Create a rule-based content switching policy by using the GUI
- Bind the content switching policy to a cache redirection virtual server by using the CLI
- Bind the content switching policy to a cache redirection virtual server by using the GUI