Example: Using Inline Invalidation

11-34 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache DOCTYPE INVALIDATIONRESULT SYSTEM internal:WCSinvalidation.dtd INVALIDATIONRESULT VERSION=WCS-1.1 OBJECTRESULT BASICSELECTOR URI=cgishow_bike.pl RESULT ID=1 STATUS=SUCCESS NUMINV=1 OBJECTRESULT INVALIDATIONRESULT -- pThanks againp body html

11.4 ESI Tag Descriptions

This section describes the following ESI tags, which are used for partial page caching operations: ■ Section 11.4.1, ESI choose | when | otherwise Tags ■ Section 11.4.2, ESI comment Tag ■ Section 11.4.3, ESI environment Tag ■ Section 11.4.4, ESI include Tag ■ Section 11.4.5, ESI inline Tag ■ Section 11.4.6, ESI invalidate Tag ■ Section 11.4.7, ESI remove Tag ■ Section 11.4.8, ESI try | attempt | except Tags ■ Section 11.4.9, ESI vars Tag ■ Section 11.4.10, ESI --esi--Tag 11.4.1 ESI choose | when | otherwise Tags The esi:choose, esi:when, and esi:otherwise conditional tags provide the ability to perform logic based on Boolean expressions.

11.4.1.1 Syntax

esi:choose esi:when test=BOOLEAN_expression Perform this action esi:when esi:when test=BOOLEAN_expression Perform this action esi:when esi:otherwise Perform this other action esi:otherwise esi:choose

11.4.1.2 Attributes

test—Specifies the Boolean operation Caching Dynamic Content with ESI Language Tags 11-35

11.4.1.3 Usage

■ Each esi:choose tag must have a least one esi:when tag, and may optionally contain exactly one esi:otherwise tag. ■ Oracle Web Cache executes the first esi:when tag whose test attribute evaluates truthfully, and then exit the esi:choose tag. If no esi:when tag evaluates to true and an esi:otherwise tag is present, that elements content executes. ■ Other HTML or ESI element can be included inside esi:when or esi:otherwise elements.

11.4.1.4 Boolean Expressions

The test attribute uses Boolean expressions to determine how to evaluate true or false logic. ESI supports the following Boolean operators: ■ == equal to ■ = not equal to ■ greater than ■ less than ■ = greater than or equal to ■ = less than or equal to ■ and ■ | or ■ not Note the following about the use of Boolean expressions: ■ Operands associate from left to right. Sub-expressions can be grouped with parentheses to explicitly specify association. ■ If both operands are numeric, then the expression is evaluated numerically. ■ If either operand is non-numeric, then both operands are evaluated as strings. For example, a==3 evaluates to a==3, where 3 is evaluated as a string. ■ The comparison of two Boolean expressions results in an undefined operation. ■ If an operand is empty or undefined, then the expression always evaluates to false. ■ The logical operators , , and| are used to qualify expressions, but cannot be used to make comparisons. ■ Use single quotes for constant strings. For example, the following string is a valid construction: HTTP_COOKIE{name}==typical ■ Escaped single quotes \ are not permitted. For example, the following is not supported: HTTP_COOKIE{user\s name}==typical ■ Arithmetic operations and assignments are not permitted. ■ A null value evaluates whether a variable is empty. 11-36 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache When a number is compared with null, that number is converted into an equivalent string and compared against an empty string. In the following ESI markup, logindata{name} is a variable that provides access to the value of the name. If name is empty and evaluates to null, then the expression evaluates to true; if name is not empty and does not evaluate to null, then the expression evaluates to false. esi:choose esi:when test=logindata{name} == null esi:include src=loginlogindata{name} esi:when esi:otherwise esi:include src=loginguest.html esi:otherwise esi:choose The following expressions show correct usage of Boolean operators: 1==1 a=c 1==1|abc==def 4=54==5 The following expressions show incorrect usage of Boolean operators: 1 4 abc | edf

11.4.1.5 Statements

Statements must be placed inside a esi:when or esi:otherwise subtag. Statements outside the subtags cannot be evaluated as conditions. Example 11–30 shows invalid placement of statements. Example 11–30 Statement Placement esi:choose This markup is invalid because any characters other than whitespace are not allowed in this area. esi:when test=HTTP_HOST == www.company.com esi:include src=company.html esi:when This markup is invalid because any characters other than whitespace are not allowed in this area. esi:when test=HTTP_COOKIE{fragment == First Fragment img src=imgTheImage.gif esi:when This markup is invalid because any characters other than whitespace are not allowed in this area. esi:otherwise The default selection. esi:otherwise This markup is invalid because any characters other than whitespace are not allowed in this area. esi:choose Note: If a variable exists but evaluates to an empty string, then the value is not considered null. Caching Dynamic Content with ESI Language Tags 11-37

11.4.1.6 Example

The following ESI markup includes advanced.html for requests that use the cookie Advanced and basic.html for requests that use the cookie Basic: esi:choose esi:when test=HTTP_COOKIE{group}==Advanced esi:include src=http:www.company.comadvanced.html esi:when esi:when test=HTTP_COOKIE{group}==Basic User esi:include src=http:www.company.combasic.html esi:when esi:otherwise esi:include src=http:www.company.comnew_user.html esi:otherwise esi:choose

11.4.2 ESI comment Tag

The esi:comment tag enables you to comment ESI instructions, without making the comments available in the output.

11.4.2.1 Syntax

esi:comment text=text commentary esi:comment is an empty element, and does not have an end tag.

11.4.2.2 Usage

The esi:comment tag is not evaluated by Oracle Web Cache. If comments must be visible in the HTML output, use standard XMLHTML comment tags.

11.4.2.3 Example

The following ESI markup provides a comment for an included GIF file: esi:comment text=the following animation will have a 24 hour TTL esi:include src=http:www.company.comlogo.gif onerror=continue

11.4.3 ESI environment Tag

The esi:environment tag enables you to include custom environment variables from included fragments. When included, these variables can then be used with the other ESI tags.

11.4.3.1 Syntax

There are two forms of this tag. In the first form, esi:environment does not have a closing esi:environment tag: esi:environment src=environment_URL name=environment_name [max-age=expiration_time [+ removal_time]] [method=GET|POST] [onerror=continue] [timeout=fetch_time] In the second form with elements, esi:environment has a closing esi:environment tag: esi:environment src=environment_URL name=environment_name [max-age=expiration_time [+ removal_time]] [method=GET|POST] [onerror=continue] [timeout=fetch_time]