ESI Language Elements in the Surrogate-Control Response Header

Caching Dynamic Content with ESI Language Tags 11-9 ■ Supported CGI environment variables are case sensitive. They are generally uppercase. ■ ESI does not support the use of whitespace next to the equal sign = or between the and esi: The following shows an invalid construction: esi:include src = www.foo.com The following shows the correct form: esi:include src=www.foo.com

11.1.5 Nesting Elements

As shown in Example 11–3 , an ESI tag can contain nested ESI elements and other HTML markup. Example 11–3 Nested ESI Elements esi:choose esi:when test=HTTP_HOST == www.company.com esi:include src=company.html h4Anotherh4 esi:include src=another.html esi:when esi:when test=HTTP_COOKIE{fragment == First Fragment esi:try esi:attempt esi:include src=fragment1.html esi:attempt esi:except esi:choose esi:when test=HTTP_COOKIE{otherchoice} == image img src=imgTheImage.gif esi:when esi:otherwise The fragment is unavailable. esi:otherwise esi:choose esi:except esi:try esi:when esi:otherwise The default selection. esi:otherwise esi:choose

11.1.6 Variable Expressions

ESI supports the HTTP request variables and environment variables used with the esi:environment tag. This section contains the following topics: ■ Section 11.1.6.1, Variable Usage ■ Section 11.1.6.2, Variable Default Values ■ Section 11.1.6.3, HTTP Request Variables 11-10 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache See Section 11.4.3 for instructions on including custom variables

11.1.6.1 Variable Usage

To refer to a variable, prefix it with a dollar sign and surround the variable name with parentheses: VARIABLE_NAME For example: HTTP_HOST Variables are accessed by a key as follows: VARIABLE_NAME{key} To access a variables substructure, append the variable name with braces containing the key which is being accessed. For example: HTTP_COOKIE{username} The key is case sensitive and optional. If a key is not specified, the environment variable returns the whole content of the environment fragment. Oracle advises specifying an environment variable without a key only for testing whether the environment is empty. In the following ESI markup, logindata is a variable that is evaluated against a null value: esi:environment src=getlogindata name=logindata esi:include src=loginlogindata{account} esi:choose esi:when test=logindata = null esi:include src=loginlogindata{account} esi:when esi:otherwise esi:include src=loginguest.html esi:otherwise esi:choose

11.1.6.2 Variable Default Values

You can use the logical OR | operator to specify a default value in the following form: VARIABLE|default A variable takes the default value only when the variable or its key does not exist. If it evaluates to an empty string, the empty string is returned, not the default value. The following example results in Oracle Web Cache fetching http:example.comdefault.html if the cookie id is not in the request: esi:include src=http:example.comHTTP_COOKIE{id}|default.html As with other literals, if whitespace must be specified, the default value must be single-quoted. For example: HTTP_COOKIE{first_name}|new user Note: HTTP_HOST and HTTP_REFERER do not support default values. Caching Dynamic Content with ESI Language Tags 11-11

11.1.6.3 HTTP Request Variables

Table 11–3 on page 11-11 lists the HTTP request variables supported by ESI. Note the following: ■ Except for QUERY_STRING, the values for the variables are taken from HTTP request-header fields. In the case of QUERY_STRING, the value is taken from either the HTTP request body or the URL. ■ Variables are only interpreted when enclosed within ESI tags. ■ Variables with a substructure type of List or Dictionary are accessed by a key. ■ Variables identified with a substructure type of Dictionary make access to strings available through their appropriate keys. ■ Dictionary keys are case sensitive. ■ Variables identified with a substructure type of List return a Boolean value depending on whether the requested value is present. Table 11–3 HTTP Request Variables Supported by ESI Variable Name HTTP Header Field Substructure TypeVariable Type Description Example HTTP_ACCEPT_ LANGUAGE{language} Accept-Language request-header field Specifies the set of languages that are preferred as a response. The language is used as the key. ListBoolean Specifies the language to use as the key and evaluates to the language specified in the HTTP request header Variable Setting: HTTP_LANGUAGE{en-gb} HTTP Request Header Contains: Accept_Language:en-gb Result: Returns en-gb. HTTP_ COOKIE{cookie} Set-Cookie response-header field or Cookie request-header field Specifies cookie name and value pairs. A cookie name is used as the key. If the Cookie request-header and Set-Cookie response-header have different values for the same cookie name, the name value pair from the Set-Cookie response header is used. Dictionary String Specifies the cookie name to use as the key and returns that cookies value Variable Setting: HTTP_COOKIE{visits} HTTP Request Header Contains: Cookie:visits=42 Result: Returns 42. HTTP_ HEADER{header} Any HTTP request header Dictionary String Specifies an HTTP request header name to use as the key and returns that headers value Variable Setting: HTTP_HEADER{Referer} HTTP Request Header Contains: Referer: http:www.company.com: 80 Result: Returns http:www.company.com: 80