Use Case: ESI support for fetching and updating content dynamically
Edge Side Includes (ESI) is a markup language for edge-level dynamic Web content assembly. It helps in accelerating dynamic Web-based applications by defining a simple markup language to describe cacheable and non-cacheable Web page components that can be aggregated, assembled, and delivered at the network edge. By using HTTP callouts on the Citrix ADC appliance, you can read through the ESI constructs and aggregate or assemble content dynamically.
To implement this configuration, you must perform the following tasks:
- Enable rewrite on the Citrix ADC appliance.
- Create an HTTP callout on the appliance and configure it with details about the external server and other required parameters.
- Configure a rewrite action to replace the ESI content with the callout response body.
- Configure a rewrite policy to specify the conditions under which the action is performed, and then bind the rewrite policy globally.
Enabling rewrite
Rewrite must be enabled before it is used on the Citrix ADC appliance. The following procedure describes the steps to enable the rewrite feature.
To enable rewrite by using the GUI
- Make sure that you have installed the rewrite license.
- In the configuration utility, expand AppExpert, and right-click Rewrite, and then click Enable Rewrite feature.
Creating an HTTP Callout on the Citrix ADC Appliance
For more information about creating an HTTP callout, seeConfiguring an HTTP Callout. For more information about the parameter values, seeParameters and Values for HTTP-Callout-2pdf.
Configuring the Rewrite Action
Create a rewrite action, Action-Rewrite-1, to replace the ESI content with the callout response body. Use the parameter settings shown in the following table.
Table 2. Parameters and Values for Action-Rewrite-1
Parameter | Value |
---|---|
Name | Action-Rewrite-1 |
Type | Replace |
Expression to choose target text reference | “HTTP.RES.BODY(500).AFTER_STR (\” |
String expression for replacement text | “SYS.HTTP_CALLOUT(HTTP-Callout-2)” |
To configure the rewrite action by using the configuration utility
- Navigate toAppExpert>Rewrite>Actions.
- In the details pane, clickAdd.
- In theCreate Rewrite Actiondialog box, in Name, typeAction-Rewrite-1.
- In Type, selectREPLACE.
InExpressionto choose target text reference, type the following default syntax expression:
"HTTP.RES.BODY(500).AFTER_STR("
").BEFORE_STR(" ")" In the String expression for replacement text, type the following string expression:
"SYS.HTTP_CALLOUT(HTTP-Callout-2)"
- ClickCreate, and then clickClose.
Creating the Rewrite Policy and Binding it Globally
Create a rewrite policy, Policy-Rewrite-1, with the parameter settings shown in the following table. You can create a rewrite policy in the Policies subnode and then bind it globally by using the Rewrite Policy Manager. Alternatively, you can use the Rewrite Policy Manager to perform both these tasks simultaneously. This demonstration uses the Rewrite Policy Manager to perform both tasks.
Table 3. Parameters and Values for Policy-Rewrite-1
Parameter | Value |
---|---|
Name | Policy-Rewrite-1 |
Action | Action_Rewrite-1 |
Undefined Result Action | -Global undefined-result action- |
Expression | “HTTP.REQ.HEADER("Name").CONTAINS ("Callout").NOT” |
To configure a rewrite policy and bind it globally by using the configuration utility
- Navigate toAppExpert>Rewrite.
- In the details pane, underPolicy Manager, clickRewrite Policy Manager.
- In theRewrite Policy Managerdialog box, clickOverride Global.
- ClickInsert Policy, and then, in thePolicy Namecolumn, clickNew Policy.
- In theCreate Rewrite Policydialog box, do the following: 1.In Name, type Policy-Rewrite-1.
- In Action, select Action-Rewrite-1.
- In Undefined-Result Action, select Global undefined-result action.
- In Expression, type the following default syntax expression:
"HTTP.REQ.HEADER("Name").CONTAINS("Callout").NOT"
- ClickCreate, and then clickClose.
- ClickApply Changes, and then clickClose.