Skip Headers

Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference
Release 2 (9.0.2)

Part Number A95883-01
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

6
JESI Tags for Edge Side Includes

This chapter describes the JESI (JSP to ESI) tag library that is supplied with OC4J. These portable tags operate on top of an Edge Side Includes (ESI) framework available in the Oracle9iAS Web Cache to provide ESI caching functionality in a JSP application.

The chapter includes the following topics:

For an overview of Web caching, including discussion of the Oracle9iAS Web Cache, the Oracle9i Application Server Java Object Cache, and the OC4J Web Object Cache, see "Overview of Oracle Caching Support for Web Applications".

Overview of Edge Side Includes Technology and Processing

This section provides background information about some of the underlying technology upon which the Oracle JESI tags are based.

JESI tags, which are used to break down dynamic content of JSP pages into cacheable components, are based upon the Edge Side Includes architecture and ESI markup language.

Although the use of JESI tags is not dependent upon any particular ESI processor or caching system, it is reasonable to assume that most Oracle customers would use the Oracle9iAS Web Cache and its ESI processor.

This section covers the following topics:

This discussion provides only a brief overview of the ESI architecture and language. For additional information about ESI technology, refer to the following Web site:

http://www.edge-delivery.org

Edge Side Includes Technology

This section introduces the features of ESI technology and the concept of ESI "surrogates".

Introduction to ESI

Edge Side Includes is an XML-style markup language that allows dynamic content assembly away from the origin Web server--at the "edge" of the network--and is designed to take advantage of available tools such as Web caches and content delivery networks (CDNs) to improve performance for end users.

ESI provides a means of reducing the load on Web and application servers by promoting processing on intermediaries, known as surrogates or reverse proxies, that understand the ESI language and act on behalf of the Web server. ESI content is intended for processing somewhere between the time it leaves the originating Web server and the time it is displayed in the end user's browser. A surrogate is commanded through HTTP headers. Such a surrogate can be referred to as an "ESI processor" and may be included as part of the functionality of a Web cache.

ESI lends itself to a partial-page caching methodology, where each dynamic portion of a Web page can be cached individually and retrieved separately and appropriately.

Using the ESI markup tags, a developer can define aggregate Web pages and the cacheable components that are to be retrieved and assembled, as appropriate, by the ESI processor for viewing in the HTTP client. You can think of an aggregate page, which is the resource associated with the URL that an end user specifies, as simply a container for assembly, including retrieval and assembly instructions that are specified through the ESI tags.


Note:

Bear in mind that a JESI user does not have to (and would typically not want to) use ESI tags directly. JESI tag handlers translate JESI tags to ESI tags behind the scenes.


More About Surrogates

Because surrogates act on behalf of Web servers, where page content is owned, they allow content owners to have sufficient control over their behavior. In this way, they offer greater potential for performance improvements than would otherwise be available.

The caching process in surrogates operates similarly to the caching process in HTTP in general, using similar freshness and validation mechanisms as the foundation. However, surrogates also possess additional control mechanisms.

Key ESI Features

Version 1.0 of the ESI language includes the following key areas of functionality:

Oracle9iAS Web Cache and ESI Processor

This section introduces the Oracle9iAS Web Cache and its ESI processor. See the Oracle9iAS Web Cache Administration and Deployment Guide for more information.

Introduction to Oracle9iAS Web Cache

Oracle offers Oracle9iAS Web Cache to help e-businesses manage Web site performance issues. It is a content-aware server accelerator, or reverse proxy server, that improves the performance, scalability, and availability of Web sites that run on the Oracle9i Application Server.

By storing pages from frequently accessed URLs in memory, Oracle9iAS Web Cache eliminates the need to repeatedly process requests for those URLs on the application Web server. Unlike legacy proxy servers that handle only static documents, Oracle9iAS Web Cache caches both static content and dynamically generated content from one or more application Web servers. As the result of more frequent cache hits, there is greater performance enhancement than with legacy proxies, and much less load on application servers.

Conceptually, Oracle9iAS Web Cache is positioned in front of application Web servers, caching their content and sending that content to Web browsers that request it. When Web browsers access the Web site, they send HTTP protocol or HTTPS protocol requests to Oracle9iAS Web Cache, which, in turn, acts as a virtual server for the application Web servers. If the requested content has expired, or has been invalidated, or is no longer accessible, then Oracle9iAS Web Cache retrieves the new content from the application Web servers.

Steps in Oracle9iAS Web Cache Usage

Here are the steps for typical browser interaction with Oracle9iAS Web Cache:

  1. A browser sends a request to the Web site of a company.

    This request, in turn, generates a request to the Domain Name System (DNS) for the IP address of the Web site.

  2. DNS returns the IP address of Oracle9iAS Web Cache.

  3. The browser sends the request for the Web page to Oracle9iAS Web Cache.

  4. If the requested content is in its cache, Oracle9iAS Web Cache sends the content directly to the browser. This is known as a cache hit.

  5. If Oracle9iAS Web Cache does not have the requested content, or the content is stale or invalid, then the Web cache hands off the request to the application Web server. This is known as a cache miss.

  6. The application Web server sends the content through Oracle9iAS Web Cache.

  7. Oracle9iAS Web Cache sends the content to the client and makes a copy of the page in cache.


    Note:

    A page that is stored in the cache is removed when it becomes invalid or outdated.


Oracle9iAS Web Cache ESI Processor

Oracle9iAS Web Cache includes an ESI processor to support the use of the Edge Side Includes markup language in caching. (See "Edge Side Includes Technology".)

Web developers in an Oracle9iAS Web Cache environment can use the ESI language directly in their applications; however, for JSP developers, there are a number of reasons to use the JESI tag library that is provided as a convenient JSP interface to the ESI language. (See "Advantages of JESI Tags".)

Overview of JESI Functionality

This section introduces JESI functionality and the Oracle implementation, covering the following topics:

You can access the proposed JESI specification at the following Web site:

http://www.edge-delivery.org

Advantages of JESI Tags

OC4J provides the JESI tag library as a convenient interface to ESI tags and Edge Side Includes functionality for Web caching. Developers have the option of using ESI tags directly in any Web application, but JESI tags provide additional convenience in a JSP environment. Here are the main advantages in using JESI tags instead of using ESI tags directly:

Overview of JESI Tags Implemented by Oracle

The Oracle implementation of JESI is layered on top of the standard ESI framework. Because the JESI tag library is a standard implementation, note the following:

The Oracle JESI tag library supports the following tags:

Included with the tag library are the following:

JSP developers use these tags (such as JESI include) instead of corresponding ESI tags (such as esi:include). The usefulness and convenience of this is discussed previously, in "Advantages of JESI Tags".


Note:

The Oracle JESI tag library is a standard library. For general information about the standard JavaServer Pages tag library framework, refer to the Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference.


JESI Usage Models

There are two models for how to use JESI tags to define aggregate pages and their cacheable components:

This section describes these models, and concludes with some special notes about the JESI include tag.

Control/Include Model

One approach to using JESI tags is a modular one, typically bringing most (or all) cacheable content into the aggregate page as included pages. Generally use this model as follows:

This document refers to this modular approach as the control/include model. It is particularly convenient in a situation where you are developing new pages.

Each included file is a distinct cacheable object (although caching may be disabled according to tag settings), and any additional content in the aggregate page is also a distinct object.

Both tags are optional, depending on the situation. A page can have a JESI control tag without any JESI include tags. In fact, this is a simple way to convert an existing page for JESI use. There is also no requirement for a JESI control tag in a page that uses JESI include tags.

For any page, either top-level or included, that does not specify cacheability through a JESI control tag, its cacheability depends on configuration settings of the ESI processor. This applies if the page has no JESI control tag, or if it has a JESI control tag that does not set the cache attribute.


Notes:

The JESI control tag in the aggregate page has no effect on included pages. An included page without its own JESI control tag uses default cache settings.


See the following sections for tag syntax and examples:

Template/Fragment Model

Another JESI tag approach is one where content is in the aggregate page itself, and you split the page into separately cacheable fragments as desired. Use the JESI template tag to enclose the aggregate of all cacheable content. This tag sets caching parameters for the aggregate page outside the fragments. Use JESI fragment tags as desired to define fragments within the aggregate, to be cached separately.

This document refers to this scenario as the template/fragment model. It is particularly convenient in a situation where you are converting existing pages for JESI use. There can optionally be JESI include tags as well, either at the template level or the fragment level.

The JESI template tag and JESI fragment tag are always used together. If you do not need separate fragments in a page, use JESI control instead of JESI template.

Each fragment is a distinct cacheable object, and dynamic content at the template level, outside of any fragments, is a distinct cacheable object. Any included page is also a distinct cacheable object. The cacheability of the template code outside the fragments depends on the cache attribute setting, if any, of the JESI template tag. The cacheability of any fragment depends on the cache attribute setting, if any, of the JESI fragment tag. The cacheability of an included page depends on the cache attribute setting of the JESI control tag, if any, within that page. For any template, fragment, or included page that does not specify a cache attribute setting, its cacheability depends on configuration settings of the ESI processor.

Because the template and fragments are independent cacheable objects, they may expire at different points in time in the ESI processor. When a cache miss occurs or an object that has expired is requested, the ESI processor will make a request to the origin server (OC4J in the case of Oracle9iAS) for a fresh copy. If a requested object is a JESI template, the JSP engine will execute the template code; that is, all code in the page that is outside any fragments. In output generated by the JSP translator, the translator will also place ESI markup that designates where all the fragments should be included. The code contained in the JESI fragments will not be executed at that time.

When a fragment expires, the ESI processor will make a request to the origin server for that particular fragment. In order to execute a fragment, the OC4J JSP container will execute the template code (all code outside of the fragments) plus the code of the fragment being requested. In the resulting page, there will be the output of the template, ESI markers for the inclusion of the other fragments, and the results of the requested fragment. These fragment results will be inserted ("inlined") into the page at the appropriate point. Upon receiving the response, the ESI processor will find the inlined fragment in the page and cache the updated copy of that fragment. The Oracle ESI processor will discard the rest of the page. (Behavior may differ in other ESI processors.) The Oracle9iAS Web Cache does not update the template when it requests a fresh fragment.

Keep this behavior in mind when choosing expiration policies for your templates and fragments. In order to divide a page into template and fragments correctly and efficiently, it is important to remember what portion of a JSP page is executed during any particular update request. For example, because the template code is executed in every update request, try not to place an expensive computation at the template level, unless it must be executed every time. It is usually preferable to place expensive computation in a fragment that has as long an expiration time as possible.

Also be aware that no two fragments are ever executed during the same request. Therefore, you should not declare or set the value of a scriptlet variable in one fragment and depend on that variable or the set value in another fragment. If a variable is needed in more than one fragment, it should be declared and set in the template code. Similarly, but perhaps less obviously, do not set a request or session attribute in one fragment and then try to read it in another fragment. Such "page global logic" should also be placed at the template level.


Important:

In Oracle9iAS 9.0.2, you cannot use the JESI template/fragment model and explicit ESI markup (such as <esi:inline> for example) within the same HTTP response.

For example, Oracle9iAS Web Cache errors will occur if there is a JSP page that uses <jesi:template> and <jesi:fragment> tags and also includes a servlet that generates HTML with <esi:inline> tags.


See the following sections for tag syntax and examples:

Notes About JESI Includes

In using either model, be aware of the following notes regarding the JESI include statement:

Invalidation of Cached Objects

There may be situations where cached objects must be explicitly invalidated due to external circumstances, such as changes to relevant data in a database. There may also be situations where execution of one page may invalidate the data of cached objects corresponding to another page.

For this reason, JESI provides the JESI invalidate tag and several subtags. These tags allow you to invalidate pages based on appropriate combinations of the following:

Invalidation messages are in an XML-based format, and specify the URLs to be invalidated. These messages are initiated by the JSP container when it executes the JESI invalidate tag, and transmitted to the cache server over HTTP using a POST method. The cache server then replies with an invalidation response, sent back over HTTP.

See "Tag and Subtag Descriptions for Invalidation of Cached Objects" for tag syntax and examples.

Personalization of Cached Pages

Dynamic Web pages frequently display customized information tailored to each individual user. For example, a welcome page may display the user's name and a special greeting, or current quotes for stocks the user owns.

For this kind of tailored output, the Web page depends on cookie information, which can be provided through the JESI personalize tag. Without this tag to inform the ESI processor of this dependency, the Web page cannot be shared by multiple users at the ESI level.

See "Tag Description for Page Personalization" for tag syntax and examples.


Note:

Do not confuse this tag with the Oracle9iAS Personalization tag library, which encompasses much more functionality. JESI personalization consists of the ESI processor simply replacing place holders in a cached page with dynamic strings that come from cookies sent in a request or response. This enables different users to share the same cached page. Oracle Personalization, using data mining on the back-end, is much more dynamic. It produces output that changes automatically according to user activity. See Chapter 9, "Oracle9iAS Personalization Tags" for more information.


Oracle JESI Tag Descriptions

This section describes the syntax and attributes for the JESI tags provided with OC4J, followed by usage examples. Discussion is organized into the following categories:

The Oracle JESI tag library, a standard JavaServer Pages tag library implementation, is included in the ojsputil.jar file, which is provided with OC4J. Verify that this file is installed and in your classpath.

To use the JESI tag library, the tag library description file, jesitaglib.tld, must be deployed with the application. In an Oracle9iAS installation, this file is in the [Oracle_Home]/j2ee/tlds directory.

In your JSP pages, you must use a taglib directive such as the following:

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>


Notes:

  • The prefix "jesi:" is used in the tag syntax here. This is by convention but is not required. You can specify any desired prefix in your taglib directive.

  • See "Tag Syntax Symbology and Notes" for general information about tag syntax conventions in this manual.

  • Except where noted otherwise, default settings are determined by the ESI processor. In the case of the Oracle9iAS Web Cache ESI processor, this is according to the cache configuration file.


Tag Descriptions for Page Setup and Content

This section summarizes the use of the following tags, and documents their syntax and attributes:

This section also provides examples of both the control/include model and the template/fragment model. See "JESI Usage Models" for overviews of these models.

JESI control Tag

The JESI control tag controls caching characteristics for JSP pages in the control/include usage model. You can use a JESI control tag in the top-level page or any included page, but it is not mandatory. For any page without a JESI control tag, or with a JESI control tag that has no cache attribute setting, cacheability is according to the configuration settings of the ESI processor. (See "JESI Usage Models".)

The JESI control tag should appear as early as possible in the page, before any other JESI tags or any buffer flushes in the page.

Be aware of the following:

Syntax

<jesi:control
             [ expiration = "value" ]
             [ maxRemovalDelay = "value" ]
             [ cache = "yes" | "no" | "no-remote" ] />


Note:

The proposed JESI specification includes a control attribute for the JESI control, JESI template, and JESI fragment tags. This attribute is for setting parameters of ESI control headers directly. The current Oracle implementation, however, supports setting only the control header max-age parameter. Setting this is unnecessary, though, because setting the expiration and maxRemovalDelay attributes of JESI control serves the same purpose. Therefore, in Oracle9iAS 9.0.2, the control attribute is not documented. (Future releases will likely support setting additional ESI control header parameters, at which time the control attribute will be documented here.)


Attributes

JESI include Tag

The JESI include tag, as with a standard jsp:include tag, dynamically inserts output from the included page into output from the including page. Additionally, it directs the ESI processor to process and assemble the included pages. Each included page is a separate cacheable object (or non-cacheable, depending on settings).

You can use this tag in either the control/include model or the template/fragment model, in any of the following scenarios:

(See "JESI Usage Models".)

The cacheability of an included page depends on the cache attribute setting of the JESI control tag (if any) within that page. If there is no cache setting, then cacheability depends on configuration settings of the ESI processor.

Although the JESI include tag has similarities in usage to jsp:include, its different semantics make it unsuitable for page inclusions where request or response objects must be passed between the originating page and the included page.

Syntax

<jesi:include page = "uri"
            [ alt = "alternate_uri" ]
            [ ignoreError = "true" | "false" ]
            [ flush = "true" | "false" ] 
            [ copyparam = "true" | "false" ] />

Attributes

Examples--Control/Include Model

This section provides examples of JESI tag usage in the control/include model.

For a complete sample application using JESI tags, refer to the OC4J demos.

Example 1: Control/Include

The following example employs default cache settings; no JESI control tag is necessary. The JESI include tags specify no alternate files, and a "file not found" error will halt processing. The flush attribute is permissible but ignored.

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>
<html>
<body>
<jesi:include page="stocks.jsp" flush="true" />
<p>
<hr>
<jesi:include page="/weather.jsp" flush="true" />
<p>
<hr>
<jesi:include page="../sales.jsp" flush="true" />
</body>
</html>

Example 2: Control/Include

This example uses the JESI control tag to specify non-default cache settings for maxRemovalDelay and expiration. In addition, it explicitly enables caching of the page, though this is already enabled by default. The first JESI include tag specifies an alternate page in case order.jsp cannot be retrieved by the ESI processor, and specifies that processing continue even if neither page can be retrieved. The second JESI include tag specifies no alternate page, and processing will halt if the page cannot be retrieved.

As you can see, the HTML tags that "Example 1: Control/Include" uses are not actually required.

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>

<jesi:control maxRemovalDelay="1000" expiration="300" cache="yes"/>
<jesi:include page="order.jsp" alt="alt.jsp" ignoreError="true"/>
<jesi:include page="commit.jsp" />

Example 3: Control/Include

This is an example of an aggregate page whose output is conditional. A cookie represents the identity of a customer. If no cookie is found, the user will see a generic welcome page with general product information. If a cookie is found, the user will see a list of products according to the user profile. This list is brought into the page through a JESI include statement.

The JESI control tag also sets non-default values for maxRemovalDelay and expiration, and explicitly enables caching for the page.

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>

<jesi:control maxRemovalDelay="1000" expiration="300" cache="yes"/>
<%
  String customerId=CookieUtil.getCookieValue(request,"customerid");

  if (customerId==null) {
    // some unknown customer 
%>
    <jesi:include page="genericwelcome.jsp" />
<%
  }
  else {
    // a known customer; trying to retrieve recommended products from profiling

    String recommendedProductsDescPages[]=
               ProfileUtil.getRecommendedProductsDescURL(customerId);

    for (int i=0; i < recommendedProductsDescPages.length; i++) {
%>
    <jesi:include page="<%=recommendedProductsDescPages[i]%>" />
<%
    }
  }
%>

Example 4: Control/Include

This example illustrates the use of JESI include statements with request parameters. Assume the main page is accessed through the following URL:

http://host:port/application1/main.jsp?p2=abc

The main page takes the parameter setting p2=abc. Here is the page:

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>
<html> 
<jesi:control cache="no" /> 
<jesi:include page="a.jsp?p1=v1" /> 
<h3>hello ...</h3> 
<jesi:include page="b.jsp" /> 
<h3>world ...</h3> 
<jesi:include page="c.jsp?p1=v2" copyparam="true" /> 
</html> 

The a.jsp page takes the parameter setting p1=v1. The c.jsp page takes the setting p1=v2 as well as the setting p2=abc (as a result of the copyparam setting and the p2 setting in the URL for the main page).

Additionally, this page is non-cacheable, according to the cache="no" setting. In fact, remember that you should use the copyparam setting in a JESI include tag only when the including page is non-cacheable, because the request attributes may change from one request to the next. Remember, too, that the cache="no" setting has no effect on the included pages--they are still cacheable by default. In other words, each is cacheable unless it has its own JESI control tag with cache="no" for some reason.

JESI template Tag

Use the JESI template tag to specify caching behavior for the aggregate page, outside any fragments, in the template/fragment usage model. (See "JESI Usage Models".) The corresponding HTTP header will be set according to the edge architecture specification. The aggregate content (outside the fragments) is a cacheable object, and each fragment set aside with a JESI fragment tag is a separate cacheable object.

Place the JESI template start tag as early in the page as possible--it must appear before any other JESI tags or any buffer flushes in the page. Place the JESI template end tag as late in the page as possible--it must appear after any other JESI tags in the page.

If a JESI template tag does not set the cache attribute, then cacheability of the corresponding object is according to configuration settings of the ESI processor.

The JESI template tag is always used together with JESI fragment tags. If you have no need for separate fragments, use a JESI control tag instead of a JESI template tag.

Be aware of the following:

The JESI template tag has the same attributes, with the same usage, as the JESI control tag.

Syntax

<jesi:template
             [ expiration = "value" ]
             [ maxRemovalDelay = "value" ]
             [ cache = "yes" | "no" | "no-remote" ] >

...page content, jesi:fragment tags, jesi:include tags...

</jesi:template>
Attributes

For attribute descriptions, see "JESI control Tag".


Note:

If request parameters are significant to the fragment, then either the enclosing template should not be cached (cache="no" in the JESI template tag), or, in the ESI server, the fragment should be cached with parameters (instead of without parameters). In the background, a fragment, as with a page included through a JESI include tag, involves an additional request. Request parameters (if any) are always passed from the template to the fragment, equivalent to JESI include tag functionality with a setting of copyparam="true". (This kind of issue is also discussed in "JESI include Tag".)


JESI fragment Tag

Use one or more JESI fragment tags within a JESI template tag, between the JESI template start and end tags, in the template/fragment model. (See "JESI Usage Models".) The JESI fragment tag defines separate fragments of JSP code, as desired, for caching behavior. Each fragment is a separate cacheable object.

When a particular fragment is requested through the ESI mechanism, the ESI processor will retrieve only that fragment.

Each JESI fragment tag specifies its own instructions to the ESI processor. If the cache attribute is not set, then cacheability of the corresponding object is according to the configuration settings of the ESI processor. The settings of the surrounding JESI template tag have no effect on the fragments.

The JESI fragment tag has the same attributes, with the same usage, as the JESI control and JESI template tags.

Syntax

<jesi:fragment
             [ expiration = "value" ]
             [ maxRemovalDelay = "value" ]
             [ cache = "yes" | "no" | "no-remote" ] >

...JSP code fragment...

</jesi:fragment>

Attributes

For attribute descriptions, see "JESI control Tag".

Examples--Template/Fragment Model

This section contains examples of JESI tag usage in the template/fragment model.

Example 1: Template/Fragment

This is a general example showing use of the JESI template and JESI fragment tags. Because only the expiration attribute is set in any of the tags, all other settings are according to defaults.

The aggregate content (outside the fragments), according to the JESI template tag, uses an expiration of 3600 seconds. This applies to all the HTML blocks because they are all outside the fragments. JSP code block #1 is cached with an expiration setting of 60; JSP code block #2 is cached with the default expiration setting; and JSP code block #3 is cached with an expiration setting of 600.

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>
<jesi:template expiration="3600"> 
...HTML block #1...
   <jesi:fragment expiration="60"> 
   ...JSP code block #1...
   </jesi:fragment> 
...HTML block #2...
   <jesi:fragment> 
   ...JSP code block #2...
   </jesi:fragment> 
...HTML block #3...
  <jesi:fragment expiration="600"> 
   ...JSP code block #3...
   </jesi:fragment> 
...HTML block #4...
</jesi:template> 

Example 2: Template/Fragment

This example employs JESI include tags inside the fragments. The following are the cacheable objects for this page:

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %>
<jesi:template expiration="3600"> 
...HTML block #1...
   <jesi:fragment expiration="60"> 
   ...JSP code block #1...
   <jesi:include page="stocks.jsp" />
   </jesi:fragment> 
...HTML block #2...
   <jesi:fragment> 
   ...JSP code block #2...
   <jesi:include page="/weather.jsp" />
   </jesi:fragment> 
...HTML block #3...
   <jesi:fragment expiration="600"> 
   ...JSP code block #3...
   <jesi:include page="../sales.jsp" />
   </jesi:fragment> 
...HTML block #4...
</jesi:template> 

Tag and Subtag Descriptions for Invalidation of Cached Objects

Use the JESI invalidate tag and the following subtags, as appropriate, to explicitly invalidate cached objects in the ESI processor:

See "Invalidation of Cached Objects" for an overview.

JESI invalidate Tag

You can use the JESI invalidate tag with its JESI object subtag to explicitly invalidate one or more cached objects.

Use the subtags as follows:

Syntax

<jesi:invalidate
             [ url = "url"
               username = "username"
               password = "password" ]
             [ config = "configfilename" ]
             [ output = "browser" ] >

Required subtag (described in "JESI object Subtag"):

             <jesi:object ... >

Optional subtag of JESI object (described in "JESI cookie Subtag"):

                   <jesi:cookie ... />

Optional subtag of JESI object (described in "JESI header Subtag"):

                   <jesi:header ... />

             </jesi:object>

</jesi:invalidate>

Either specify the user, password, and URL all through their individual tags, or all in the configuration file referred to in the config attribute.


Note:

It is permissible to have multiple object tags within an invalidate tag.


Attributes

Example: Configuration File

Following is an example of a configuration file that is used instead of the url, username, and password attributes to set the URL and login information.

<?xml version="1.0" ?>
<ojsp-config>
  <web-cache>
      <url>http://yourhost.yourcompany.com:4001</url>
      <username>invalidator</username>
      <password>invpwd</password>
  </web-cache>
</ojsp-config>

JESI object Subtag

Use the required JESI object subtag of the JESI invalidate tag to specify cached objects to invalidate, according to either the complete URI or a URI prefix. Optionally use its JESI cookie subtag or JESI header subtag to specify further criteria for invalidation, based on cookie or HTTP header information.

Specify either the complete URI or the URI prefix in the uri attribute setting. Whether this field is interpreted as a full URI or as a prefix depends on the setting of the prefix attribute.

Syntax

<jesi:object uri = "uri_or_uriprefix"
           [ maxRemovalDelay = "value" ]
           [ prefix = "yes" | "no" ] >

Optional subtag (described in "JESI cookie Subtag"):

                   <jesi:cookie ... />

Optional subtag (described in "JESI header Subtag"):

                   <jesi:header ... />

</jesi:object>

or (if not using either subtag):

<jesi:object
              uri = "uri_or_uriprefix"
            [ maxRemovalDelay = "value" ] 
            [ prefix = "yes" | "no"] />


Notes:

  • It is permissible to have multiple object tags within an invalidate tag.

  • It is permissible to have multiple cookie tags or header tags within an object tag.


Attributes

JESI cookie Subtag

Use the JESI cookie subtag of the JESI object tag (which is a subtag of JESI invalidate) to use cookie information as a further criterion for invalidation. This is used in addition to the URI or URI prefix setting in the JESI object tag, and possibly in addition to a JESI header tag as well.

Syntax

<jesi:cookie name = "cookie_name"
             value = "cookie_value" />


Note:

It is permissible to have multiple cookie tags within an object tag.


Attributes

For a cached object to be invalidated, it must have a cookie that matches this name and value.

JESI header Subtag

Use the JESI header subtag of the JESI object tag (which is a subtag of JESI invalidate) to use HTTP/1.1 header information as a further criterion for invalidation. This is in addition to the URI or URI prefix setting in the JESI object tag, and possibly in addition to a JESI cookie tag as well.

Syntax

<jesi:header name = "header_name"
             value = "header_value" />


Note:

It is permissible to have multiple header tags within an object tag.


Attributes

For a cached object to be invalidated, it must have a header that matches this name and value.

Examples--Page Invalidation

This section provides examples of page invalidation using the JESI invalidate tag, its JESI object subtag, and the JESI cookie subtag of the JESI object tag.

Example 1: Page Invalidation

This example invalidates a single object in the ESI processor, specified by its complete URI. (By default, uri specifies a full URI, not a URI prefix.) The JESI invalidate tag also specifies the URL for the cache server and the user name and password for login, and it specifies that the invalidation response from the cache server should be displayed in the user's browser.

...
<jesi:invalidate url="http://yourhost.yourcompany.com:4001"
                 username="invalidator" password="invpwd"
                 output="browser">
     <jesi:object uri="/images/logo.gif"/>
</jesi:invalidate>
...

Example 2: Page Invalidation

This is equivalent to Example 1: Page Invalidation, but uses a configuration file to specify the cache server URL and login information.

...
<jesi:invalidate config="/myconfig.xml" output="browser">
     <jesi:object uri="/images/logo.gif"/>
</jesi:invalidate>
...

The JESI invalidate tag uses application-relative syntax for the configuration file. As an example, suppose that myconfig.xml has the following content:

<?xml version="1.0" ?>
<ojsp-config>
  <web-cache>
      <url>http://yourhost.yourcompany.com:4001</url>
      <username>invalidator</username>
      <password>invpwd</password>
  </web-cache>
</ojsp-config>

Example 3: Page Invalidation

This example invalidates all objects in the ESI processor, according to the URI prefix "/". It does not specify that the invalidation confirmation message be displayed in the browser, so it will not be displayed at all.

...
<jesi:invalidate url="http://yourhost.yourcompany.com:4001"
                 username="invalidator" password="invpwd">
     <jesi:object uri="/" prefix="yes"/>
</jesi:invalidate>
...

Example 4: Page Invalidation

This example invalidates a single object but allows it to be served stale for up to 30 minutes (1800 seconds).

...
<jesi:invalidate url="http://yourhost.yourcompany.com:4001"
                 username="invalidator" password="invpwd">
     <jesi:object uri="/images/logo.gif" maxRemovalDelay="1800"/>
</jesi:invalidate>
...

Example 5: Page Invalidation

This example specifies the same object for invalidation as Example 1: Page Invalidation, but specifies that it should be invalidated only if it has a cookie named user_type with value customer.

...
<jesi:invalidate url="http://yourhost.yourcompany.com:4001"
                 username="invalidator" password="invpwd">
     <jesi:object uri="/images/logo.gif">
          <jesi:cookie name="user_type" value="customer"/>
     </jesi:object>
</jesi:invalidate>
...

Tag Description for Page Personalization

To allow page customization when sharing the same cached page between multiple users, the ESI processor must be informed of dependencies by the page on cookie and session information. Cookie value replacement, for example, occurs in the ESI processor instead of in the Web server.

JESI personalize Tag

Use the JESI personalize tag to allow page customization, by informing the ESI processor of dependencies on cookie and session information.

Syntax

<jesi:personalize name = "cookie_name"
                [ value = "default_value" ] />
Attributes

Example--Page Personalization

Following is an example showing use of the JESI personalize tag:

<jesi:personalize name="user_id" value="guest" />

The corresponding ESI tag that is generated allows the ESI processor to find the necessary information. In this case, it looks for a cookie named user_id and retrieves its value. If it cannot find the cookie, it uses a default value of "guest". Handling this cookie-value replacement in the ESI processor avoids having to send a request to the Web server.

JESI Tag Handling and JESI-to-ESI Conversion

JESI tag handler classes, supplied as part of the JESI tag library with OC4J, provide the bridge from JSP functionality to ESI functionality. Tag handlers translate JESI tags into ESI tags and, as appropriate, generate HTTP requests for invalidation, set HTTP response headers, and so on. Be aware, however, that there is not always a simple one-to-one mapping between JESI tags and ESI tags, or between JESI tag attributes and ESI tag attributes.

Example: JESI-to-ESI Conversion for Included Pages

As an example of JESI-to-ESI conversion, consider the following JSP code:

<p>BEGIN</p> 
<jesi:control cache="no"/>
<jesi:include page="stocks.jsp" flush="true" /> 
<p> 
<hr> 
<jesi:include page="/weather.jsp" copyparam="true" flush="true" /> 
<p> 
<hr> 
<jesi:include page="../sales.jsp?tax=local" copyparam="true" flush="true" /> 
<p>END</p> 

Assume that this JSP code is part of a page with the following URL:

http://host:port/application1/top.jsp

Further assume the following request:

http://host:port/application1/top.jsp?city=Washington_DC

In this case, the JESI include tag handler generates ESI code such as in the following response.

In the response header:

Surrogate-Control: content="ESI/1.0",max-age=300+0 

In the response body:

<p>BEGIN</p> 
<esi:include src="/application1/stocks.jsp"/> 

<p> 
<hr> 
<esi:include src="/weather.jsp?city=Washington_DC"/> 

<p> 
<hr> 
<esi:include src="/sales.jsp?tax=local&city=Washington_DC"/> 

<p>END</p> 

This response is read by the ESI processor before being delivered to the client. A Surrogate-Control header alerts the ESI processor that the response body contains ESI code; therefore, the caching mechanism looks inside the response body for <esi:> tags. In addition, the Surrogate-Control header sets the cache expiration and maximum delay interval for the page, in this case using the default expiration of 300 and the default maximum delay of 0 because there is no JESI control tag to specify otherwise.

In response to each of the three esi:include tags, the ESI processor makes an additional request to the URL specified. Each response is included into the top-level page, and only after that is the assembled page delivered to the client. Note that the client receives one response, but the cache makes four requests to obtain it. This may seem like a lot of overhead; however, the overall efficiency will be improved if many additional requests also use the same included pages, such as weather.jsp. No requests for these pages are required, because they are cached separately on the ESI server.

Example: JESI-to-ESI Conversion for a Template and Fragment

Suppose that when employees connect to a corporate intranet site, the content of their pages is dynamic, except for a few features that are present in every response. In particular, there is always a footer displaying the stock chart and latest business headlines for the company, and the business headlines are obtained from an external business news site. Because all returned pages will have to include the same information, and it is expensive to obtain, it is more efficient to cache the footer on the ESI server.

The remainder of the page response is dynamic, incorporating the stock fragment in a slightly different way each time. To avoid having to rewrite the page, you can mark the footer as a JESI fragment and the enclosing page as a JESI template.

Also assume that a charity campaign is in progress, and that the organizers want to display a bar chart showing their goal amount and the current donation amount as part of all corporate pages. This information is stored in a special database and is updated twice a day. The chart is a good candidate to be an additional JESI fragment.

Therefore, you would add a JESI template tag at the top of the page and use JESI fragment tags to enclose the fragments that are to be cached as separate entities.

Assume the URL to the corporate page is as follows:

http://www.bigcorp.com/employee_page.jsp

Further assume you have modified the page as follows:

<%@ taglib uri="/WEB-INF/jesitaglib.tld" prefix="jesi" %> 
<jesi:template cache="no" > 

<p>BEGIN</p> 
... some dynamic page content... 
<jesi:fragment> 
This_is_the_body_of_Charity_Chart 
</jesi:fragment> 
... some more dynamic content... 
<jesi:fragment> 
This_is_the_body_of_Business_Footer 
</jesi:fragment> 
<p>END</p>

When the page is requested, an HTTP response is generated as follows.

In the response header:

Surrogate-Control: content="ESI/1.0",max-age=300+0,no-store

In the response body:

<p>BEGIN</p> 
... some dynamic page content... 
<esi:include src="/employee_page.jsp?__esi_fragment=1"/> 
... some more dynamic content... 
<esi:include src="/employee_page.jsp?__esi_fragment=2"/> 
<p>END</p> 

As with the JESI include example in "Example: JESI-to-ESI Conversion for Included Pages", the ESI server is alerted by the Surrogate-Control response header. Note the no-store directive, generated because of the cache="no" setting in the JESI template tag. In addition, the default expiration of 300 and the default maximum delay of 0 are used, because the JESI template tag does not specify otherwise.

The ESI server makes two additional requests, where it fetches and caches the two fragments. After that, the composite page is returned to the employee. When the employee works with the page again, the dynamic content will be newly generated, but the chart and the footer will be served from the cache.


Note:

Surrogate-Control headers are consumed by the ESI server and are not seen in the final response to the client.



Go to previous page Go to next page
Oracle
Copyright © 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index