ESI choose | when | otherwise Tags

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] 11-38 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache [esi:request_header name=request_header value=value] [esi:request_body value=value] [esi:loglog_messageesi:log] esi:environment

11.4.3.2 Attributes

■ src—Specifies the URL from which to obtain environment variables and their values. The URL can be either an absolute or relative URL. When specifying an absolute URL, use the following formats: ■ http:host_name:portpathfilename ■ https:host_name:portpathfilename If you specify the host name for an absolute URL, you must prefix it with http: or https:. An HTML parser treats the host:80 in the following URL as a folder name rather than a host name: src=host:80index.htm To make this URL valid, you specify the following: src=http:host:80index.htm Relative URLs are resolved relative to the template page. The result sets the ESI environment for the current template. The source code of the URL requires the following XML format: ?xml version=1.0? esi:environment esiversion=ORAESI9.0.4 variable_namevariable_valuevariable_name variable_namevariable_valuevariable_name esi:environment ■ name—Specifies the name to use to refer to the environment variable. ■ method—Specifies the HTTP request method of the environment fragment. Valid values are GET or POST. ■ max-age—Specifies the time, in seconds, to expire the XML file, and optionally, specifies the time, in seconds, to remove the XML file after the expiration time. ■ timeout—Specifies the time, in seconds, for the fragment to be fetched. If the fragment has not been fetched within the time interval, the fetch is aborted. ■ onerror—Specifies that if the fetch failed on the src object, to ignore the ESI tag and serve the page.

11.4.3.3 Elements

■ request_body—Specifies the HTTP request body of the fragment. ■ request_header—Specifies an HTTP request header field and value for Oracle Web Cache to use. ■ log—Specifies a log message of the fragment to be included in the access_log_ file .fragment file when the x-esi-info log field is set. You can provide a descriptive text string that identifies the fragment and the application that generated the fragment. By providing descriptive text, you can easily identify the Caching Dynamic Content with ESI Language Tags 11-39 fragment in the log file, enabling you to determine how often the fragment is requested. See Table 9–5 on page 9-15 for further information about the x-esi-info log field.

11.4.3.4 Syntax Usage

■ Specify only one esi:environment tag for each template page, before other ESI tags. ■ The attributes do not have to be in a particular order. ■ Do not specify multiple request_body elements. ■ You can have zero or more request_header elements. Use multiple request_header elements to specify multiple HTTP request header fields: esi:environment src=environment_URL [max-age=expiration_time [+ removal_time]][method=GET|POST] [onerror=continue] [timeout=fetch_time] esi:request_header name=request_header value=value esi:request_header name=request_header value=value esi:environment ■ If no request_header elements are specified, Oracle Web Cache uses other request headers from the parent page. ■ Do not specify multiple log elements. For more information, see: ■ Section 11.1.6 for usage instructions for variables ■ Section 11.4.4 for usage notes on max-age, method, onerror, request_body, and request_header ■ Section 11.1.7 for usage notes on onerror

11.4.3.5 Example

The following ESI output specifies logindata to refer to the environment variables stored in catalog.xml. The file catalog.xml enables access to the value of the vendorID environment variable, which is used as a parameter in the included URL: esi:environment src=catalog.xml name=logindata esi:include src=http:provider.comintranetprovider?vendorID=logindata{vendorID} The file catalog.xml has the following content: ?xml version=1.0? esi:environment esiversion=ORAESI9.0.4 product_descriptionstereoproduct_description vendorID3278vendorID partner1E-Electronicspartner1 partner2E-Citypartner2 esi:environment The following ESI output specifies logindata to refer to the environment variables stored in env.dat. The file env.dat enables access to the value of the env environment variable, which is used as a parameter in the included log message for dir1.txt. The log messages for dir1.txt and esi-log2.html are written to the 11-40 Oracle Fusion Middleware Administrators Guide for Oracle Web Cache access_log .fragment file when the x-esi-info log field is set and the fragments are requested. esi:environment src=esienv.dat name=env esi:logUsed environment esienv.datesi:log esi:environment esi:include src=cacheddir1.txt esi:logFragment:cachedir1.txt is included, by env{xl_name}esi:log esi:include font color=redIncluding cgi-binesi-fetch.sh?esiesi-log2.html in esi-log1.html font esi:include src=cgi-binesi-fetch.sh?esiesi-log2.html esi:logFragment: cgi-binesi-fetch.sh?esiesi-log2.html is included esi:log

11.4.4 ESI include Tag

The esi:include tag provides syntax for including fragments. See Section 11.1.8 for a comparison of esi:inline and esi:include usage.

11.4.4.1 Syntax

There are two forms of this tag. In the first form, esi:include does not have a closing esi:include tag: esi:include src=URL_fragment [alt=URL_fragment] [max-age=expiration_time [+removal_time]] [method=GET|POST] [onerror=continue] [redirect=yes|no] [timeout=fetch_time] In the second form, with elements, esi:include has a closing esi:include tag: esi:include src=URL_fragment [alt=URL_fragment] [max-age=expiration_time[+removal_time]] [method=GET|POST] [onerror=continue] [redirect=yes|no] [timeout=fetch_time] [esi:request_header name=request_header value=value] [esi:request_body value=value] [esi:loglog_messageesi:log] esi:include

11.4.4.2 Attributes

■ src—Specifies the URL of the fragment to fetch. The URL can be a literal string or it can include variables. The URL can either be an absolute or relative URL. When specifying an absolute URL, use the following formats: ■ http:host_name:portpathfilename ■ https:host_name:portpathfilename If you specify the host name for an absolute URL, you must prefix it with http: or https:. An HTML parser treats the host:80 in the following URL as a folder name rather than a host name: src=host:80index.htm To make this URL valid, you specify the following: