Skip Headers
Oracle® Application Server Web Cache Administrator's Guide
10g Release 2 (10.1.2)
Part No. B14046-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

16 Edge Side Includes (ESI) Language Tags

This chapter describes the Edge Side Includes (ESI) tags provided for content assembly of dynamic fragments.

This chapter contains these topics:

Overview of ESI

ESI is an open specification co-authored by Oracle. Its purpose is to develop a uniform programming model to assemble dynamic pages in a dynamic content cache deployed as a surrogate or proxy between browsers and origin servers.

ESI is an XML-like markup language that enables dynamic content assembly of fragments by OracleAS Web Cache. A template page is configured with ESI markup tags that fetch and include dynamic HTML fragments. The fragments themselves can also contain ESI markup. You can assign caching rules to the template page and HTML fragments. By enabling page assembly in OracleAS Web Cache rather than in the application Web server, you can increase cache hit rates and improve performance.

The following topics provide an overview of ESI usage:

Supported ESI Language Elements

To enable OracleAS Web Cache to process ESI tags, you set an HTTP Surrogate-Control response-header field in the HTTP response message of the pages that use ESI tags.

OracleAS Web Cache supports the ESI language tags, elements, and attributes listed in Table 16-1. The rightmost column specifies, for each ESI tag, attribute, or element, all the feature sets that support it. For example, the <esi:invalidate> tag is only supported by the "ESI-INV/1.0" feature set. To enable the correct processing in OracleAS Web Cache, specify all the feature sets that an ESI template uses in the content control directive of the Surrogate-Control response header. However, you do need to specify features sets used within an ESI fragment directly or indirectly included in the template. For example, if an ESI template uses an <esi:invalidate> and an <esi:environment> tag with an <esi:log> element, the content control directive must include "ESI-INV/1.0" and "ORAESI/9.0.4", as follows:

Surrogate-Control: content="ESI-INV/1.0 ORAESI/9.0.4"

See Also:

"Using the Surrogate-Control Response Headeras an Alternative to Caching Rules" for further information about configuring the Surrogate-Control response header

Table 16-1 ESI Language Features

ESI Language Feature See Also content="value" Control Directive in Surrogate-Control Response Header Supporting Feature
<esi:choose> | <esi:when> | <esi:otherwise> tags "ESI choose | when | otherwise Tags"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<esi:comment> tag "ESI comment Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<esi:environment> tag "ESI environment Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

<esi:include> tag "ESI include Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<esi:environment> tag and <esi:include> tag attributes and elements  
 
alt attribute "ESI include Tag"
"ORAESI/9.0.4"

"ESI/1.0"

max-age attribute "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"

"ORAESI/9.0.2"

onerror attribute "ESI include Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

src attribute "ESI include Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

timeout attribute "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"

"ORAESI/9.0.2"

<esi:log> element "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"
<esi:request_header> element "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"

"ORAESI/9.0.2"

<esi:request_body> element "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"

"ORAESI/9.0.2"

<esi:inline> tag "ESI inline Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI-Inline/1.0"

"ESI/1.0"

name attribute "ESI inline Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI-Inline/1.0"

"ESI/1.0"

fetchable attribute "ESI inline Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI-Inline/1.0"

"ESI/1.0"

max-age attribute "ESI inline Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

timeout attribute "ESI include Tag"

"ESI environment Tag"


"ORAESI/9.0.4"

"ORAESI/9.0.2"

<esi:invalidate> tag "ESI invalidate Tag"
"ESI-INV/1.0"
<esi:remove> tag "ESI remove Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<esi:try> | <esi:attempt> | <esi:accept> tags "ESI try | attempt | except Tags"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<esi:vars> tag "ESI vars Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"

<!--esi...---> tag "ESI <!--esi-->Tag"
"ORAESI/9.0.4"

"ORAESI/9.0.2"

"ESI/1.0"



See Also:

http://www.esi.org/spec.html for the ESI Language Specification 1.0 and the Edge Architecture Specification

Syntax Rules

ESI elements and attributes adhere to XML syntax but can be embedded in other objects, such as HTML or XML objects. When OracleAS Web Cache processes the page, the ESI elements themselves are stripped from the output.

ESI syntax generally adheres to XML syntax rules. Keep the following in mind when using the tags:

  • ESI tags and attributes are case sensitive.

    They are generally lowercase.

  • 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"/>

Nesting Elements

As shown in Example 16-1, an ESI tag can contain nested ESI elements and other HTML markup.

Example 16-1 Nested ESI Elements

<esi:choose>
  <esi:when test="$(HTTP_HOST) == 'www.company.com'">
    <esi:include src="/company.html" />
    <h4>Another</h4>
    <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="/img/TheImage.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>

Variable Expressions

ESI supports the HTTP request variables and environment variables used with the <esi:environment> tag.

This section contains the following topics:

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 variable's 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="/login/$(logindata{account})"/">
<esi:choose>
  <esi:when test="$(logindata) != null">
    <esi:include src="/login/$(logindata{account})"/>
 </esi:when>
 <esi:otherwise>
   <esi:include src="/login/guest.html"/>
 <esi:otherwise>
</esi:choose>  

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 OracleAS Web Cache fetching http://example.com/default.html if the cookie id is not in the request:

<esi:include src="http://example.com/$(HTTP_COOKIE{id}|default).html"/>

As with other literals, if whitespace needs to 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.

HTTP Request Variables

Table 16-2 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 16-2 HTTP Request Variables Supported by ESI

Variable Name HTTP Header Field Substructure Type/Variable 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.

List/Boolean 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 cookie's 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 header's value Variable Setting:

$(HTTP_HEADER{Referer})

HTTP Request Header Contains:

Referer: http://www.company.com:80

Result: Returns

http://www.company.com:80

$HTTP_HOST Host request-header field

Specifies the host name and port number of the resource. Port 80 is the default port number.

Not Applicable/String Returns the value of the HOST header Variable Setting:

$(HTTP_HOST)

HTTP Request Header Contains:

Host:http://www.company.com:80

Result: Returns

http://www.company.com:80

$HTTP_REFERER Referer request-header field

Specifies the URL of the reference resource

Not Applicable/String Returns the value of the REFERER header Variable Setting:

$(HTTP_REFERER)

HTTP Request Header Contains:

Referer: http://www.company.com:80

Result: Returns

http://www.company.com:80

$(HTTP_USER_AGENT{browser})

$HTTP_USER_AGENT{version})

$HTTP_USER_AGENT{os})

User-Agent request-header field

Specifies the Web browser type, browser version, or operating system that initiated the request.

Dictionary/String Specifies one of three keys: browser for browser type, version for browser version, and os for operating system Variable Setting:

$(HTTP_USER_AGENT{browser})

HTTP Request Header Contains:

User-Agent:Mozilla/4.0 (compatible, MSIE 5.5, Windows)

Result: Returns MSIE

$(HTTP_USER_AGENT{version})

Result: Returns 4.0.

$(HTTP_USER_AGENT{os})

Result: Returns Windows

$(QUERY_STRING{parameter}) Not Applicable Dictionary/String Given a parameter name in a query string, returns the value of the parameter without URL encoding. The query string can be in an URL or a request body.

See Also: http://www.rfc-editor.org/ for further information about URL encoding.

Variable Setting:

$(QUERY_STRING{CEO})

Query Request Contains:

CEO=Jane%20Doe&CFO=John%20Doe

Result: Returns the value of fullname decoded. In this example, CEO returns a value of Jane Doe.

$(QUERY_STRING) Not Applicable Not Applicable/String Specifies to return the entire query string encoded Variable Setting:

$(QUERY_STRING)

Query Request Contains:

CEO=Jane%20Doe&CFO=John%20Doe

Result: Returns the entire query string encoded:

CEO=Jane%20Doe&CFO=John%20Doe

$(QUERY_STRING_ENCODED{parameter}) Not Applicable Dictionary/String Given a parameter name in a query string, returns the value of the parameter with URL encoding. The query string can be in an URL or a request body. Variable Setting:

$(QUERY_STRING{fullname})

Query Request Contains:

fullname=Jane%20Doe

Result: Returns the value of fullname encoded:

Jane%20Doe

$(QUERY_STRING_ENCODED) Not Applicable Not Applicable/String The same as $(QUERY_STRING) Variable Setting:

$(QUERY_STRING_ENCODED)

Query Request Contains:

fullname=Jane%20Doe

Result: Returns the entire query string encoded:

fullname=Jane%20Doe

$(QUERY_STRING_DECODED{parameter}) Not Applicable Dictionary/String The same as $(QUERY_STRING{parameter}) Variable Setting:

$(QUERY_STRING_DECODED{CEO})

Query Request Contains:

fullname=Jane%20Doe

Result: Returns the value of fullname decoded. In this example, fullname returns a value of Jane Doe.


Exceptions and Errors

ESI uses several mechanisms to handle exceptions encountered during an ESI fragment request. In a given situation, you can make use of all mechanisms simultaneously, or use one at a time, depending on the business logic you are developing.

The first mechanism is found in the ESI language, which provides three specific elements for fine-grain control over content assembly in error scenarios:

  • The alt attribute of the <esi:include> tag

  • The onerror attribute of the <esi:include> tag

  • The try |attempt |except block

  • Default page in place of the fragment

When the fragment specified for the src attribute of the <esi:include> tag cannot be fetched, the fragment specified with the alt attribute is used as an alternative. If the alt attribute is not used or the fragment cannot be fetched, the onerror attribute is used. The onerror attribute is used before the try |attempt |except block. If the try |attempt |except block does not exist, the exception handling is propagated to the parent or template page. If all the ESI language controls fail, OracleAS Web Cache displays a default page in place of the fragment.


See Also:



ESI Tag Descriptions

This section describes the following ESI tags, which are used for partial page caching operations:


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.

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>

Attributes

test—Specifies the Boolean operation

Usage

Boolean Expressions

The test attribute uses Boolean expressions to determine how to evaluate true or false logic. ESI supports the following Boolean operators:

Note the following about the use of Boolean expressions:

The following expressions show correct usage of Boolean operators:

!(1==1)
!('a'<='c')
(1==1)|('abc'=='def')
(4!=5)&(4==5)

The following expressions show incorrect usage of Boolean operators:

(1 & 4)
("abc" | "edf")

Statements

Statements must be placed inside a <esi:when> or <esi:otherwise> subtag. Statements outside the subtags cannot be evaluated as conditions. Example 16-2 shows invalid placement of statements.

Example 16-2 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="/img/TheImage.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>

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.com/advanced.html"/>
  </esi:when>
  <esi:when test="$(HTTP_COOKIE{group})=='Basic User'">
    <esi:include src="http://www.company.com/basic.html"/>
  </esi:when>
  <esi:otherwise>
    <esi:include src="http://www.company.com/new_user.html"/>
  </esi:otherwise>
</esi:choose>

ESI comment Tag

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

Syntax

<esi:comment text="text commentary"/>

<esi:comment> is an empty element, and does not have an end tag.

Usage

The <esi:comment> tag is not evaluated by OracleAS Web Cache. If comments need to be visible in the HTML output, use standard XML/HTML comment tags.

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://wwww.company.com/logo.gif" onerror="continue" />


ESI environment Tag

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

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"]>
  [<esi:request_header name="request_header" value="value"/>]
  [<esi:request_body value="value"/>]
  [<esi:log>log_message</esi:log>]
</esi:environment>

Attributes

Elements

Syntax Usage

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.com/intranetprovider?vendorID=$(logindata{vendorID})"/>

The file catalog.xml has the following content:

<?xml version="1.0"?>
<esi:environment esiversion="ORAESI/9.0.4">
  <product_description>stereo</product_description>
  <vendorID>3278</vendorID>
  <partner1>E-Electronics</partner1>
  <partner2>E-City</partner2>
</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 access_log.fragment file when the x-esi-info log field is set and the fragments are requested.

<esi:environment src="/esi/env.dat" name="env">
  <esi:log>Used environment /esi/env.dat</esi:log>
</esi:environment>

<esi:include src="/cached/dir1.txt">
  <esi:log>Fragment:/cache/dir1.txt is included, by $(env{xl_name})</esi:log>
</esi:include>

<font color="red">Including /cgi-bin/esi-fetch.sh?/esi/esi-log2.html in esi-log1.html </font>
<esi:include src="/cgi-bin/esi-fetch.sh?/esi/esi-log2.html">
  <esi:log>Fragment: /cgi-bin/esi-fetch.sh?/esi/esi-log2.html is included
 </esi:log>


ESI include Tag

The <esi:include> tag provides syntax for including fragments.


See Also:

"Fragmentation with the Inline and Include Tags" for a comparison of <esi:inline> and <esi:include> usage

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:log>log_message</esi:log>]
</esi:include>

Attributes

Elements

Syntax Usage

Usage

The <esi:include> tag instructs OracleAS Web Cache to fetch the fragment specified by the src attribute.

If the include is successful, the contents of the fetched src URL are displayed. The included object is included exactly at the point of the include tag. For example, if the include tag is in a table cell, the fetched object is displayed in the table cell.

The max-age control directive in the Surrogate-Control response-header field applies to the response; the max-age attribute applies only to that particular usage of the fragment response through the <esi:include> tag. If both the max-age control directive in the Surrogate-Control response-header field and the max-age attribute are set, then the effective expiration and removal time-to-live for this particular inclusion are the longest maximum age of the expiration and the removal time-to-live, respectively. If a particular page has a greater tolerance for staleness of a fragment, then set the max-age attribute to a longer time than the max-age control directive. Use the max-age attribute to increase cache hits by serving fragments stale until the removal time. max-age=infinity specifies that the object never expires.

If method is not set, then GET is assumed. However, if the request_body element is set, then POST is assumed.

OracleAS Web Cache generates the following HTTP request headers for all fragment requests:

The request_header element enables you to control HTTP headers other than these. Do not specify these HTTP request headers as request_header attributes, as a conflict can affect the operation of OracleAS Web Cache.

If no request_header elements are specified, OracleAS Web Cache uses other request headers from the parent page.


See Also:

"Fragmentation with the Inline and Include Tags" for a comparison of <esi:inline> and <esi:include> usage

Examples

The following ESI markup includes a file named frag1.htm. The fragment must be fetched within 60 seconds. If the fetch fails, OracleAS Web Cache ignores the includes and serves the page. If the fetch succeeds, OracleAS Web Cache includes the fragment. OracleAS Web Cache expires the fragment after five minutes, and removes it after another eight minutes.

<esi:include src="/frag1.htm" timeout="60" maxage="300+480" onerror="continue"/>

The following ESI output includes the result of a dynamic query:

<esi:include src="/search?query=$QUERY_STRING(query)"/>

The following ESI output includes a personalized greeting, a Cookie HTTP request header, and an HTTP request body that includes the date. Log message "Fragment: /Personalized Greeting is included" is written to the access_log.fragment file when the x-esi-info log field is set and the fragment is requested.

<esi:include src="/PersonalGreeting">
  <esi:request_header name="Cookie" value="pname=Scott Tiger"/>
  <esi:request_body value="day=05, month=10, year=2001"/>
  <esi:log>Fragment: /Personalized Greeting is included</esi:log>
</esi:include>

See Also:

"Example of a Portal Site Implementation" for an extended example of <esi:include> usage


ESI inline Tag

The <esi:inline> tag marks a fragment as a separately cacheable fragment, embedded in the HTTP response of another object. OracleAS Web Cache stores and assembles these fragments independently as <esi:include> fragments.


See Also:

"Fragmentation with the Inline and Include Tags" for a comparison of <esi:inline> and <esi:include> usage

Syntax

<esi:inline name="URL" fetchable="yes|no" 
 [max-age="expiration_time [+ removal_time]"] [timeout="fetch_time"]
 Embedded HTML code
</esi:inline>

Attributes

Usage

Some inline fragments are only delivered as part of an HTTP response for another object. These are not independently fetchable by OracleAS Web Cache the way <esi:include> fragments are. When a non-fetchable fragment is needed by OracleAS Web Cache, OracleAS Web Cache must request the object from which the inline fragment was extracted.

When a non-fetchable <esi:inline> fragment is not found in the cache, OracleAS Web Cache re-fetches the fragment's parent template. This behavior implies that the parent cannot be another non-fetchable <esi:inline> fragment. If the parent is an <esi:inline> non-fetchable fragment, the response is returned to the browser is undefined.

Example

The following ESI output embeds financial headlines:

<esi:inline name="/Top_News_Finance">
Latest News for Finance
<TABLE>
  <TR>
    Blue-Chip Stocks Cut Losses; Nasdaq Up MO
    French rig factory with explosives New York Times
    Volkswagen faces Brazil strike CNN Europe
    Airbuss reliability record BBC
  </TR>
</TABLE>
</esi:inline>

See Also:

"Example of a Portal Site Implementation" for an extended example of <esi:inline> usage


ESI invalidate Tag

The <esi:invalidate> tag enables you to configure an invalidation request within the response of a browser page.

Syntax

Basic invalidation syntax:

<esi:invalidate [output="yes"]>
 <?xml version="1.0"?>
 <!DOCTYPE INVALIDATION SYSTEM "internal:///WCSinvalidation.dtd">
  <INVALIDATION VERSION="WCS-1.1">
    <SYSTEM>
     <SYSTEMINFO NAME="name" VALUE="value"/>
    </SYSTEM>  
    <OBJECT>
      <BASICSELECTOR URI="URL"/>
      <ACTION REMOVALTTL="TTL"/>
      <INFO VALUE="value"/>
    </OBJECT>
 </INVALIDATION>
</esi:invalidate>

Advanced invalidation syntax:

<esi:invalidate [output="yes"]>
 <?xml version="1.0"?>
 <!DOCTYPE INVALIDATION SYSTEM "internal:///WCSinvalidation.dtd">
 <INVALIDATION VERSION="WCS-1.1">
    <SYSTEM>
     <SYSTEMINFO NAME="name" VALUE="value"/>
    </SYSTEM>  
       <OBJECT>
         <ADVANCEDSELECTOR URIPREFIX="prefix"
                           URIEXP="URL_expression"
                           HOST="host_name:port"
                           METHOD="HTTP_request_method"
                          BODYEXP="HTTP_body"/>
          <COOKIE NAME="cookie_name" VALUE="value"/>
          <HEADER NAME="HTTP_request_header" VALUE="value"/>
          <OTHER NAME="URI|BODY|QUERYSTRING_PARAMETER|SEARCHKEY"
                 TYPE="SUBSTRING|REGEX"
                 VALUE="value"/>
         </ADVANCEDSELECTOR>
      <ACTION REMOVALTTL="TTL"/>
      <INFO VALUE="value"/>
      </OBJECT>
 </INVALIDATION>
</esi:invalidate>

Attributes

Usage

Example


ESI remove Tag

The <esi:remove> tag allows for specification of non-ESI markup output if ESI processing is not enabled with the Surrogate-Control header or there is not an ESI-enabled cache.

Syntax

<esi:remove> HTML output...</esi:remove>

Usage

Any HTML or ESI elements can be included within this tag, except other <esi:remove> tags. Note that nested ESI tags are not processed.

Example

The following ESI markup includes http://www.company.com if the <esi:include> content cannot be included:

<esi:include src="http://www.company.com/ad.html"/>
<esi:remove>
  <A HREF="http://www.company.com">www.company.com</A>
</esi:remove>

Normally, when OracleAS Web Cache processes this example block, it fetches the ad.html file and includes it into the template page while silently discarding the <esi:remove> tag and its contents. If ESI processing is not enabled, all of the elements are passed through to browser, which ignores ESI markup. However, the browser displays the <A HREF=...> HTML link.


ESI try | attempt | except Tags

The <esi:try> tag provides for exception handling. The <esi:try> tag must contain exactly one instance of an <esi:attempt> tag and one or more <esi:except> tags.


See Also:

"Exceptions and Errors" for usage notes on alt and onerror

Syntax

In the following form, only one <esi:except> tag is supported:

<esi:try>
  <esi:attempt>
    Try this...
  </esi:attempt>
  <esi:except>
    If the attempt fails, then perform this action...
  </esi:except>
</esi:try>

In the following form, multiple <esi:except> tags with different types are supported:

<esi:try>
  <esi:attempt>
    Try this...
  </esi:attempt>
  <esi:except [type="type"]>
    If the attempt fails, then perform this action...
  </esi:except>
  <esi:except [type="type"]>
    Perform this action...
  </esi:except>
  <esi:except>
    If the attempt fails, then perform this action...
  </esi:except>
</esi:try>

Usage

OracleAS Web Cache first processes the contents of <esi:attempt>. A failed <esi:attempt> triggers an error and causes OracleAS Web Cache to process the contents of the <esi:except> tag.

Specify an <esi:except> tag without a type for general errors; specify an <esi:except> tag with a type for specific errors. The <esi:except> tag accepts the following case-insensitive types:

Example

The following ESI markup attempts to fetch an advertisement. If the advertisement cannot be included, OracleAS Web Cache includes a static link instead.

<esi:try>
  <esi:attempt>
    <esi:comment text="Include an ad"/>
    <esi:include src="http://www.company.com/ad1.htm"/>
  </esi:attempt>
  <esi:except>
    <esi:comment text="Just write some HTML instead"/>
    <a href=www.company.com>www.company.com</a>
  </esi:except>
</esi:try>

The following ESI markup attempts to fetch a fragment. If the fragment cannot be included because of httpclienterror, then OracleAS Web Cache includes /cgi-bin/esi-fetch?/esi/tryNestL1.html instead.

<esi:try>
  <esi:attempt>
    <esi:include src="/frag.html"/>
  </esi:attempt>
  <esi:except type="httpclienterror">
    <esi:include src="/cgi-bin/esi-fetch?/esi/tryNestL1.html"/>
  </esi:except>
</esi:try>

The following <esi:try> attempts to include the fragment http://server.portal.com/pls/ppcdemo/!PCDEMO.wwpro_app_provider.execute_portlet/513104940/26 containing several HTTP request headers. If the fragment cannot be included because of various type errors, OracleAS Web Cache returns an Unknown ESI Exception error.

<esi:try>
  <esi:attempt>
    <esi:include src="http://server.portal.com/pls/ppcdemo/!PCDEMO.wwpro_app_provider.execute_portlet/513104940/26" timeout="15000" >
      <esi:request_header name="X-Oracle-Device.MaxDocSize" value="0"/>
      <esi:request_header name="Accept" 
      value="text/html,text/xml,text/vnd.oracle.mobilexml"/>
      <esi:request_header name="User-Agent" 
        value="Mozilla/4.0 (compatible; MSIE 5.5; Windows; YComp 5.0.0.0) 
        RPT-HTTPClient/0.3-3"/>
      <esi:request_header name="Device.Orientation" value="landscape"/>
      <esi:request_header name="Device.Class" value="pcbrowser"/>
      <esi:request_header name="PORTAL-SUBSCRIBER" value="us"/>
      <esi:request_header name="Device.Secure" value="false"/>
      <esi:request_header name="PORTAL-SUBSCRIBER-DN"
         value="dc=us,dc=oracle,dc=com"/>
      <esi:request_header name="PORTAL-SUBSCRIBER-GUID"
         value="A5EE385440E6252BE0340800208A8B00"/>
      <esi:request_header name="Accept-Language" value="en-us"/>
      <esi:request_header name="PORTAL-USER-DN"
         value="cn=public,cn=users,dc=us,dc=oracle,dc=com"/>
      <esi:request_header name="PORTAL-USER-GUID"
         value="A5EE55B396E22651E0340800208A8B00"/>
      <esi:request_header name="Content-Type"
         value="application/x-www-form-urlencoded"/>
    </esi:include>
  </esi:attempt>
  <esi:except type="incompatiblefragmentversion" >
     This happens when a fragment's processing requirement is not supported 
     or not compatible with the template.
  </esi:except>
  <esi:except type="noconnection" >
     The cache is unable to connect to the origin server serving this fragment.
  </esi:except>
  <esi:except type="nestingtoodeep" >
     The fragment include depth has exceeded the maximum include depth. The
     default value defined in Web Cache is 3.
  </esi:except>
  <esi:except type="httpservererror" >
     The origin server returns an HTTP 5xx status code, a server error.
  </esi:except>
  <esi:except type="httpclienterror" >
     The origin server returns an HTTP 4xx status code, a client error, such as
     a malformed HTTP request or an unauthorized access.
  </esi:except>
  <esi:except type="incorrectresponseheader" >
     This happens when the response headers for a fragment cause the error.
  </esi:except>
  <esi:except type="incorrectxmlfragment" >
     This happens when there is any kind of error in OracleAS Web Cache XSLT
     retrieval, parsing, or processing.
  </esi:except>
  <esi:except type="originserverbusy" >
     The origin server for this fragment is busy and cannot accept new requests
     now. This is caused by OracleAS Web Cache-to-origin server request queue
    limit.
  </esi:except>
  <esi:except type="networktimeout" >
     This is thrown by a fragment whose request to the origin server has timed
     out in the network connection. 
  </esi:except>
  <esi:except type="incorrectesifragment" >
     An error is encountered when OracleAS Web Cache tries to parse or process
     the ESI fragment response body due to errors in the body.
  </esi:except>
  <esi:except>
     Unknown ESI Exception
  </esi:except>
</esi:try>


ESI vars Tag

The <esi:vars> tag enables you to use variables outside of ESI tags. For example, instead of specifying a variable inside a <esi:include> or <esi:choose> block, you can use the <esi:vars> tag to specify a variable inside HTML code.

Syntax

<esi:vars>Optional HTML code $(VARIABLE_NAME{key}) Optional HTML code</esi:vars>

Syntax Usage

Usage


See Also:

"Variable Expressions" and "ESI environment Tag" for usage of HTTP request variables and custom variables

Example

The following ESI markup includes the cookie type and its value as part of the included URL:

<esi:vars>
  <IMG SRC="http://www.example.com/$(HTTP_COOKIE{type})/hello.gif"/>
</esi:vars>

The following ESI output refers to logindata as part of the <A HREF=...> link for the Welcome page. logindata refers to an XML file that contains custom environment variables. The output also includes the user's sessionID and category type cookie values as part of the other <A HREF=...> links.

<esi:vars>
  <A HREF="welcome.jsp?name=$(logindata{name})">
  <A HREF="/shopping.jsp?sessionID=$(QUERY_STRING{sessionID})&type=$(QUERY_STRING{type})">
  <IMG SRC="/img/shopping.gif">
  </A>
  <A HREF="/news.jsp?sessionID=$(QUERY_STRING{sessionID})&type=$(QUERY_STRING{type})">
  <IMG SRC="/img/news.gif">
  </A>
  <A HREF="/sports.jsp?sessionID=$(QUERY_STRING{sessionID})&type=$(QUERY_STRING{type})">
  <IMG SRC="/img/sports.gif">
  </A>
  <A HREF="/fun.jsp?sessionID=$(QUERY_STRING{sessionID})&type=$(QUERY_STRING{type})">
  <IMG SRC="/img/fun.gif">
  </A>
  <A HREF="/about.jsp?sessionID=$(QUERY_STRING{sessionID})&type=$(QUERY_STRING{type})">
  <IMG SRC="/img/about.gif">
  </A>
 </esi:vars>


ESI <!--esi-->Tag

The <!--esi...---> tag enables HTML marked up with ESI tags to display to the browser without processing the ESI tags. When a page is processed with this tag, OracleAS Web Cache removes the starting <!--esi and ending --> elements, while still processing the contents of the page. When the markup cannot be processed, this tag assures that the ESI markup will not interfere with the final HTML output.

Syntax

<!--esi
 ESI elements
-->

Usage

Any ESI or HTML elements can be included within this tag, except other <!--esi...--> tags.

Example

In the following ESI markup, the <!--esi and --> are removed in the final
output. The output displays the content generated by <p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p>, 
plus any surrounding text.

<!--esi  
 <p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p>
-->

If the ESI markup cannot be processed, then the <p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p> is displayed in the HTML output.