Oracle9iAS Web Cache Administration and Deployment Guide
Release 2.0.0

Part Number A90372-04
Go To Documentation Library
Library
Go To Product List
Services
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

6
Creating Rules for Cached Content

This chapter explains how to configure cacheability rules.

This chapter contains these topics:

Cacheability Rules Overview

Using Oracle Web Cache to specify cacheability rules, you can select to cache or not to cache content for static documents, multiple-version documents, personalized pages, pages that support session tracking, and HTTP error messages.

This section discusses the following topics:

Cacheability Rule Creation

Generally, when you assign cacheability rules, you specify the regular expression matching the URL and whether you want the documents contained within the URL cached or not cached. You then order the cacheability rules in order of priority. Higher priority rules are matched first.

For cacheable regular expressions that contain a document or a subset of documents that are not cacheable, give the non-cacheable documents a higher priority than the cacheable documents. For example, if you want all URLs containing /cec/cstage?ecaction=ecpassthru to be cached except for /cec/cstage?ecaction=ecpassthru2, you would enter the rules in the following order:

  1. ^/cec/cstage\?ecaction=ecpassthru2, GET and GET with query string, Don't Cache

  2. ^/cec/cstage\?ecaction=ecpassthru.*, GET and GET with query string, Cache

Note that GET and GET with query string are the HTTP request methods used by the documents.

If the order were reversed, all documents starting with /cec/cstage?ecaction=ecpassthru would be cached, including /cec/cstage?ecaction=ecpassthru2.

Examples of content that administrators would typically declare non-cacheable include updating transactions, shopping cart views, personal account views, and so on. One of the easiest ways to set up cacheability rules in Oracle Web Cache is either to first specify the non-cacheable content, and then use a broad "catch-all" rule for the cacheable content, or to first specify the cacheable content followed by a non-cacheable catch-all rule. In practice, cacheable and non-cacheable rules can be interspersed.

In addition to the URL, you can specify optional selectors for more fine-grained cacheability rules. These additional selectors include the HTTP request method (GET, GET with query string, or POST) and, if POST is selected, the HTTP POST body of the documents. In the following rule list, Rule 2 caches documents of the URL that use the GET and GET with query string methods, and Rule 3 caches documents of the URL that use the POST method and a POST body matching action=search.

  1. ^/cec/cstage\?ecaction=ecpassthru2, GET and GET with query string, Don't Cache

  2. ^/cec/cstage\?ecaction=ecpassthru.*, GET and GET with query string, Cache

  3. ^/cec/cstage\?ecaction=ecpassthru.*, POST, action=search, Cache


    Note:

    If no cacheability rules are specified, then Oracle Web Cache behaves just as HTTP proxy cache does, that is, it relies on HTTP header information to determine what is cacheable. Generally, HTTP proxy caches store only pages with static content. 


Cacheability Rule Syntax

Note that cacheability rules use regular expression syntax, which is based on the POSIX 1003 extended regular expressions for URLs, as supported by Netscape Proxy Server 2.5.

When using POSIX regular expression, keep the following syntax rules in mind:

Table 6-1 shows examples of content to cache and how to enter regular expression syntax for corresponding cacheability rules for that content.

Table 6-1 Regular Expression Examples

Content to Cache  Regular Expression Syntax 

URL beginning with /machine/doc and ending in *.gif 

^/machine/doc/.*\.gif$ 

All Graphics Interchange Format (GIF) images 

\.gif$ 

/robots.txt file 

^/robots.txt$ 

All procedures in the new_employee package 

^/pls/enroll_db/new_employee 

Default Cacheability Rules

Figure 6-1 displays the default cacheability rules established when Oracle Web Cache is installed.

Figure 6-1 Default Cacheability Rules


Text description of cache5.gif follows
Text description of the illustration cache5.gif

Table 6-2 describes the default cacheability rules.

Table 6-2 Default Cacheability Rules

URL Expression  Cache/Don't Cache  Description 

\.pdf$ 

Don't Cache 

Instructs Oracle Web Cache to not cache documents ending in .pdf 

\.html?$ 

Cache 

Instructs Oracle Web Cache to cache all .htm and .html files 

\.jpe?g$ 

Cache 

Instructs Oracle Web Cache to cache .jpg and .jpeg (JPEG) files 

\.gif$ 

Cache 

Instructs Oracle Web Cache to cache .gif (GIF) files 

\.js$ 

Cache 

Instructs Oracle Web Cache to cache .js (JavaScript) files 


Note:

Oracle Web Cache cannot cache HTTP multi-part responses to HTTP Range requests. If the application Web servers that Oracle Web Cache sends HTTP requests to return certain documents in multi-part format, configure these documents as non-cacheable. For example, certain browsers send Range requests for PDF documents; therefore, the cacheability rules for all PDF documents should be set non-cacheable. 


Configuring Cacheability Rules

To configure cacheability rules:

  1. Start Oracle Web Cache Manager.

    See Also:

    "Starting Oracle Web Cache Manager" 

  2. In the navigator pane, select Administering Web Sites > Cacheability Rules.

    The Cacheability Rules page appears in the right pane.

  3. In the Cacheability Rules page, choose Create if no rules exist. If rules already exist, select a rule, and then choose Insert Above or Insert Below.

    The Create Cacheability Rule or Edit/Create Cacheability Rule dialog box appears.

  4. In the URL Expression field, enter regular expression syntax, matching the URLs to which you want the cacheability rule to apply.

    Remember to use "^" to denote the start of the URL and "$" to denote the end of the URL.

  5. In the Method section, select to cache documents that use GET, GET with query string, or POST HTTP request methods.

    You select more than one request method.


    Note:

    If your Web site's GET with query string or POST methods are used for forms that make changes to the application Web servers or database, do not select Get with query string or POST. These options should only be selected if the forms are used in search forms. 


  6. If you selected POST in Step 5, specify the HTTP POST body of the documents in the POST Body Expression field.

    To apply this rule to any POST request body, enter ".*" in the field.

  7. Select Cache or Don't Cache for the documents contained within the URL.

  8. Optionally, to help track the meaning of rules, enter a comment for the cacheability rule in the Comment field.

  9. In ESI Output Permission, select either Yes or No.

  10. Select options for the columns that apply, and then choose Submit:

    Compression

    Select No to not serve compressed cacheable and non-cacheable documents for browsers.

    Select Yes to serve compressed cacheable and non-cacheable documents for browsers, and then select one of the following options:

    • Compress for all browsers to serve compressed documents to all browser types

    • Compress for non-Netscape browsers only to serve compressed documents for all browsers other than Netscape

    Important: Netscape browsers are unable to uncompress included files, which may result in Netscape failures. If a document will be included in other files, such as a JavaScript file, then select Compress for non-Netscape browsers only.

    Notes:

    • Oracle Corporation recommends not compressing images, such as GIFs and JPEGs, as well as executables and files that are already zipped with utilities like WinZip and GZIP. Compressing these files incurs additional overhead without the benefits of compression.

    • Even if compression is turned on, Oracle Web Cache does not compress documents containing the following:

      - A Content-Encoding header, which is typically used to denote compression

      - Session-encoded URLs, the <!--WEBCACHETAG--> and <!-- WEBCACHEEND--> tags, ESI tags, or other dynamic content that requires modification after compression

    Expiration Rule

    From the list, select an expiration rule to apply to the documents. If you do not see an expiration rule suitable for the documents, then choose Create A New Rule to create a new rule.

    See Also: Step 4 in "Configuring Expiration Rules"

    Multiple Documents with the Same Selector by Cookies

    Select None to not have Oracle Web Cache cache multiple-version documents that use cookies.

    Select Apply the following to cache multiple-version documents that rely on category cookie values, and then select the required cookie rules. If you do not see a cookie rule that can be applied to these documents, then choose Create A New Rule to create a new policy or modify an existing policy.

    See Also: Step 4 in "Configuring Rules for Multiple-Version Documents Containing Cookies"

    Multiple Documents with the Same Selector by Other Headers

    Select the HTTP request headers whose values Oracle Web Cache will use to cache and identify multiple-version documents.

    Accept: Specifies which media types are acceptable for the response

    Accept-Charset: Specifies which character sets are acceptable for the response

    Accept-Encoding: Restricts the content-encodings that are acceptable in the response

    Accept-Language: Specifies the set of languages that are preferred as a response

    User-Agent: Contains information about the Web browser that initiated the request

    An example of a request made with a Netscape 4.6 browser with HTTP request headers follows:

    User-Agent: Mozilla/4.61 [en] (WinNT; U)
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, 
    image/png,*/*
    Accept-Encoding: gzip
    Accept-Language: en
    Accept-Charset: iso-8859-1,*,utf-8
    
    

    Note: Oracle Web Cache does not interpret the values of these HTTP request headers. If the values for two pages are different, Oracle Web Cache caches both pages separately. For example, if one request sends an HTTP request header of User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0) and another request sends an HTTP request header of User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) for different versions of Internet Explorer, Oracle Web Cache serves two pages.

    Session/Personalized Attribute Related Caching Rules

    Select None to not have Oracle Web Cache cache documents that use session information contained within a session cookie or embedded in a URL as a parameter.

    Select Apply the following to cache documents with session information, and then select the required session rules. If you do not see the session these documents require, then choose Create A New Rule to create a new rule.

    See Also: "Configuring Rules for Pages with Session Tracking" for further information about creating session-related caching rules

    Simple Personalization

    Select No to cache documents with personalized attributes or session-encoded URLs.

    Select Yes to cache documents with personalized content, and then select one of the following options:

    • pages do not contain HREFs that are session encoded URLs to cache substitution instructions for only personalized attributes

    • pages contain HREFs that are session encoded URLs to cache substitution instructions for both personalized attributes and session-encoded URLs

    Important: To use the personalized attribute feature, enclose the personalized attribute information with the <!-- WEBCACHETAG--> and the <!-- WEBCACHEEND--> HTML tags.

    See Also: "Configuring Rules for Pages with Simple Personalization" for further information about creating rules for personalized pages

    HTTP Error Caching

    Enter the HTTP error codes you want Oracle Web Cache to cache. If you enter multiple codes, use a comma to separate them. If there is a problem on the application Web servers that will remain unresolved, then cache the error until the problem is resolved. Once the problem is resolved, you should invalidate the cached HTTP errors.

    See Also: "Invalidating Documents in the Cache"

  11. Repeat Steps 3 through 10 for each cacheability rule.

Once the cacheability rules are configured, prioritize them.

To assign priority to rules:

  1. In the Cacheability Rules page, select a cacheability rule, and then choose Move Up or Move Down to order the rules.

    Higher priority rules are processed first.

  2. Apply changes and restart Oracle Web Cache:

    1. In the Oracle Web Cache Manager main window, choose Apply Changes.

    1. In the navigator pane, select Administering Oracle Web Cache > Web Cache Operations.

      The Oracle Web Cache Operations page appears in the right pane.

    2. In the Oracle Web Cache Operations page, choose Stop and then Start to restart Oracle Web Cache.

Cacheability Rule Example

Figure 6-2 illustrates how an administrator might set up cacheability rules for a catalog built on Oracle iStore 3i technology, which enables e-merchants to design, build, and publish their stores on the World Wide Web. Note that rules for Oracle iStore 11i will differ.

Figure 6-2 Cacheability Rules Example


Text description of cache7.gif follows
Text description of the illustration cache7.gif

The rules are described in Table 6-3.

Table 6-3 Regular Expression Examples

Priority Order  URL Expression  HTTP Method(s)  Cache/Don't Cache  Description 

1  

template=walkin\.en\.htm 

GET, GET with query string 

Cache 

Caches the home page, including personalized information 

2 

ecpassthru2 

GET, GET with query string 

Don't Cache 

Does not cache this template, because it contains customized user account information 

ecpassthru 

GET, GET with query string 

Cache 

Caches this template, because it does not contain customized content 

\.jpe?g$ 

GET, GET with query string 

Cache 

Caches .jpg and .jpeg files 

\.gif$ 

GET, GET with query string 

Cache 

Caches .gif files 

\.html?$ 

GET, GET with query string 

Cache 

Caches all .htm and .html files 

\.js$ 

GET, GET with query string 

Cache 

Caches .js files 

ecprditmsearch 

POST 

Cache 

Caches the search results 

eclogout 

GET, GET with query string 

Don't Cache 

Does not cache logout results 

10 

eccartview 

GET, GET with query string 

Don't Cache 

Does not cache the shopping cart  

11 

ecacctroot 

GET, GET with query string 

Don't Cache 

Does not cache the account view 

12 

\.pdf$ 

GET, GET with query string 

Don't Cache 

Does not cache pages ending in .pdf 

13 

.* 

GET, GET with query string 

Cache 

Caches everything else in the Web site 


Note:

Implementations of Oracle iStore can be customized. Therefore, these cacheability rules will not apply in all Oracle iStore deployments. 


Configuring Expiration Rules

You can create rules for when to expire documents in the cache. In addition, you can specify how long documents can reside in the cache once they have expired. When a document expires, it is either immediately invalidated or invalidated based on when the application Web servers can refresh them.

To create expiration rules:

  1. Start Oracle Web Cache Manager.

    See Also:

    "Starting Oracle Web Cache Manager" 

  2. In the navigator pane, select Administering Web Sites > Cacheability Rules > Expiration Rules.

    The Expiration Rules page appears in the right pane.

  3. In the Expiration Rules page, choose Add.

    The Create Expiration Rule dialog box appears.

  4. In the Expire section, specify when to expire documents by selecting one of the following options:

    Expire <time> after cache entry

    Select this option to base expiration on when the documents entered the cache. Enter the number of seconds to expire the documents.

    Expire <time> after document creation

    Select this option to base expiration on when the documents were created. Enter the number of seconds to expire the documents.

    Expires as per HTTP Expires header

    Select this option to respect the HTTP Expires header. This is the default. In order to utilize this option, documents must be programmed to use the HTTP Expires header.

    While the first two options enable you to set expiration for Oracle Web Cache-specific rules, the third option recognizes the expiration policy established for the documents already programmed with an HTTP Expires header.

  5. In the After Expiration section, specify how you want Oracle Web Cache to process documents once they have expired:

    Remove immediately

    Select this option to have Oracle Web Cache mark documents as invalid and then remove them immediately. A document is refreshed from the application Web server when the cache receives the next request for it.

    Refresh on demand as application Web server capacity permits AND no later than <time> after expiration

    Select this option to have Oracle Web Cache mark documents as invalid and then refresh them based on application Web server capacity. Enter the maximum time in which the documents can reside in the cache.


    Note:

    Performance assurance heuristics apply when you configure documents to be refreshed based on when the application Web servers can refresh them; performance assurance heuristics do not apply when documents are immediately removed. 


  6. Choose Submit.

  7. Repeat Steps 3 through 6 for each expiration rule.

  8. In the Expiration Rules page, select the newly-created rule, and then choose Change Selector Association.

    The Change Policy-Selector Association dialog box appears.

  9. Select a selector from the right list, and then choose the Make Association button.

    The selector moves to the left list and the dialog box closes.

    If the selector you require does not exist, then create a cacheability rule, as described in "Configuring Cacheability Rules". In Step 10 of the procedure, select an expiration rule in the Expiration Rule row of the Edit/Create Cacheability Rule dialog box.

  10. Apply changes and restart Oracle Web Cache:

    1. In the Oracle Web Cache Manager main window, choose Apply Changes.

    1. In the navigator pane, select Administering Oracle Web Cache > Web Cache Operations.

      The Oracle Web Cache Operations page appears in the right pane.

    2. In the Oracle Web Cache Operations page, choose Stop and then Start to restart Oracle Web Cache.

Configuring Rules for Multiple-Version Documents Containing Cookies

See Also:

"Multiple Versions of the Same Document" for an overview and an example scenario 

You can specify which category cookies whose values Oracle Web Cache will use to cache and identify multiple-version documents.

To specify cookie values for multiple-version URLs:

  1. Start Oracle Web Cache Manager.

    See Also:

    "Starting Oracle Web Cache Manager" 

  2. In the navigator pane, select Administering Web Sites > Caching Rules > Multiple Documents with the Same Selector by Cookies.

    The Multiple Documents with the Same Selector by Cookies page appears in the right pane.

  3. In the Multiple Documents with the Same Selector by Cookies page, choose Create or Add.

    The Edit/Create Multiple Documents with the Same Selector by Cookies Rule dialog box appears.

  4. In the Enter cookie name field, enter the name of the cookie.

  5. For the prompt Also cache documents whose requests do not contain this cookie?, select either Yes or No.

    • Select Yes to cache versions of the document that do not contains this cookie. This option enables Oracle Web Cache to serve documents from the cache for browser requests that do not use contain this cookie

    • Select No to not cache versions of documents that do not contain this cookie.

  6. In the Edit/Create Multiple Documents with the Same Selector by Cookies Rule dialog box, choose Submit.

  7. In the Multiple Documents with the Same Selector by Cookies page, select the newly-created rule, and then choose Change Selector Association.

    The Change Policy-Selector Association dialog box appears.

  8. Select a selector from the right list, and then choose the Make Association button.

    The selector moves to the left list and the dialog box closes.

    If the selector you require does not exist, then create a cacheability rule, as described in "Configuring Cacheability Rules". In Step 10 of the procedure, select Apply the following and a rule in the Multiple Documents with the Same Selector by Cookies row of the Edit/Create Cacheability Rule dialog box.

  9. Repeat Steps 3 through 9 for each rule.

  10. Apply changes and restart Oracle Web Cache:

    1. In the Oracle Web Cache Manager main window, choose Apply Changes.

    1. In the navigator pane, select Administering Oracle Web Cache > Web Cache Operations.

      The Oracle Web Cache Operations page appears in the right pane.

    2. In the Oracle Web Cache Operations page, choose Stop and then Start to restart Oracle Web Cache.

Configuring Rules for Multiple-Version Documents Containing HTTP Request Headers

See Also:

"Multiple Versions of the Same Document" for an overview and an example scenario 

You can specify which HTTP request headers whose values Oracle Web Cache will use to cache and identify multiple-version URLs. If a browser request passes a URL with one of the headers defined, then Oracle Web Cache serves the document from its cache.

To specify HTTP request headers for multiple-version documents, select one of the headers in the Multiple Documents with the Same Selector by Other Headers column of the Edit/Create Cacheability Rule dialog box.

See Also:

"Configuring Cacheability Rules" 

Configuring Rules for Pages with Simple Personalization

You can specify cacheability rules for personalized pages that use personalized attributes or session-encoded URLs.

Personalized attributes are often in the form of a personalized greeting like "Hello, Name." Personalized attributes can come in other forms, such as icons, addresses, or shopping cart snippets. You can configure Oracle Web Cache to cache the instructions for substituting values for personalized attributes based on the information contained within a cookie or the embedded URL parameter.

Session-encoded URLs enable Web sites to keep track of user sessions through session information contained within <A HREF=...> HTML tags. Oracle Web Cache can cache the instructions for replacing session information for one user with another based on the personal information contained within a cookie or as an embedded URL parameter.

See Also:

 

To create rules for personalized pages:

  1. Start Oracle Web Cache Manager.

    See Also:

    "Starting Oracle Web Cache Manager" 

  2. As necessary, create attribute definition(s) for those pages with personalized attributes and session definition(s) for those pages with session-encoded URLs:

    1. In the navigator pane, select Administering Web Sites > Session Management > Session/Personalized Attribute Definitions.

      The Session/Personalized Attribute Definitions page appears in the right pane.

    1. In the Session/Personalized Attribute Definitions page, choose Add.

      The Create Session/Personalized Attribute Definition dialog box appears.

    2. In the Session/Attribute field, enter an easy-to-remember unique name for the attribute or session.

      For example, if the attribute is for a personalized greeting that uses the first name, you could enter first_name01 for the session name.

    3. Enter the cookie name in the Cookie Name field and/or the embedded URL parameter in the URL Parameter field.

      If you enter both a cookie name and an embedded URL parameter, keep in mind that both must support the same personalized attribute or session substitution. If they support different substitutions, create separate personalized definitions. You can specify up to 20 definitions for each page.


      Note:

      Ensure that the size of cookies is not greater than 3 KB.  


    4. In the Default Value (Optional) field, enter a default string that Oracle Web Cache will use for the cookie or embedded URL parameter value. Oracle Web Cache uses the default string for those requests without the cookie or parameter information. For these requests, Oracle Web Cache substitutes the personalized attribute or session ID information with the default string. The default string defaults to default.

    5. In the Comment field, enter a description of the definition.

    6. Choose Submit.

  3. Configure the pages that use personalized attributes with the <!-- WEBCACHETAG--> and<!-- WEBCACHEEND--> as follows:

     <!-- WEBCACHETAG="personalized_attribute"-->
    personalized attribute HTML segment
    <!-- WEBCACHEEND-->
    
    

    Ensure that both tags have a space after <!--.


    Important:

    The <!-- WEBCACHETAG--> and <!-- WEBCACHEEND--> tags cannot be used on a page that contains ESI tags for content assembly and partial page caching. If you require simple personalization and are using ESI, see "Using ESI for Simple Personalization"



    Note:

    The <!-- WEBCACHETAG--> and<!-- WEBCACHEEND--> tags can appear anywhere the <!-- ...--> comment tags are permitted in HTML. For example, you can use the <!-- WEBCACHETAG--> and<!-- WEBCACHEEND--> tags between other HTML tag pairs, but you cannot use them within an HTML tag.

    In the following example, the placement of <!-- WEBCACHETAG="p_name"--> within the <input> tag is an invalid use of the <!-- WEBCACHETAG-->:

    htp.p('<form action="test" method="GET">'); 
    htp.p('<table border="0" > 
             <tr> 
             <td><input type="text" name="p_name" size="8" 
    value="<!--
      WEBCACHETAG="p_name"-->'||p_name||'<!-- 
    WEBCACHEEND-->"></td> 
             </tr> 
             <tr> 
             <td><input type="submit" value="Search"></td> 
             </tr> 
      </table>'); 
    

    To achieve personalization within an HTML tag, use ESI.

    See Also: "Example of Simple Personalization with Variable Expressions" 


  4. Create a cacheability rule for the personalized pages, as described in "Configuring Cacheability Rules".

    In Step 10 of the procedure, select Yes in the Simple Personalization row of the Edit/Create Cacheability Rule dialog box, and then select one of the following options:

    • pages do not contain HREFs that are session encoded URLs to cache substitution instructions for only personalized attributes

    • pages contain HREFs that are session encoded URLs to cache substitution instructions for both personalized attributes and session-encoded URLs

  5. Apply changes and restart Oracle Web Cache:

    1. In the Oracle Web Cache Manager main window, choose Apply Changes.

    1. In the navigator pane, select Administering Oracle Web Cache > Web Cache Operations.

      The Oracle Web Cache Operations page appears in the right pane.

    2. In the Oracle Web Cache Operations page, choose Stop and then Start to restart Oracle Web Cache.

Example: Personalized Page Configuration

To understand how to cache personalized content, consider the HTML page monthly.htm in Figure 6-3.

Figure 6-3 monthly.htm


Text description of personal.gif follows.
Text description of the illustration personal.gif

October is personalized content that can be substituted with other values.

The page has a URL of monthly.htm?Month=month, where Month is an embedded URL parameter.

The following steps were performed to cache monthly.htm and its personalized content.

  1. A personalized attribute of TestMonth was mapped to the embedded URL parameter Month in the Edit/Create Session/Personalized Attribute Definition dialog box.

    Figure 6-4 Edit/Create Session/Personalized Attribute Definition Dialog Box


    Text description of cachea.gif follows
    Text description of the illustration cachea.gif
  2. A session-related caching rule was created that uses the embedded URL parameter Month in the Add Session/Personalized Attribute Related Caching Rule dialog box.

    Figure 6-5 Add Session/Personalized Attribute Related Caching Rule Dialog Box


    Text description of personaa.gif follows.
    Text description of the illustration personaa.gif

    See Also:

    "Configuring Rules for Pages with Session Tracking" for more information about creating personalized attribute caching rules 

  3. The <!-- WEBCACHETAG--> and <!-- WEBCACHEEND--> HTML tags were added to monthly.htm.

    Current Month is:
    <!-- WEBCACHETAG="TestMonth"-->October<!-- WEBCACHEEND-->
    
    
  4. A cacheability rule is created for monthly.htm in the Create Cacheability Rules dialog box

    1. In the Session/Personalized Attribute Related Caching Rules row, the personalized attribute caching rule for the embedded URL Month was chosen.

    1. In the Simple Personalization row, Yes and pages contain HREFs that are session encoded URLs are chosen to cache substitution instructions for both personalized attributes and session-encoded URLs.

      Figure 6-6 Create Cacheability Rule Dialog Box


      Text description of cache6.gif follows
      Text description of the illustration cache6.gif
  5. The configuration changes are applied:

    1. In the Oracle Web Cache Manager main window, Apply Changes is chosen.

    1. In the Oracle Web Cache Operations page, Oracle Web Cache is stopped and then restarted.

To verify that Oracle Web Cache was caching monthly.htm:

  1. An initial request for monthly.htm at URL monthly.htm?Month=October was requested. Because the initial request was forwarded by Oracle Web Cache to the application Web server, the value October was required for the Month parameter. This initial request inserted monthly.htm into the cache.

  2. A subsequent request for monthly.htm was sent to URL monthly.htm?Month=January.

    Oracle Web Cache substituted October with the value of January.

    Figure 6-7 monthly.htm When Cached


    Text description of personab.gif follows.
    Text description of the illustration personab.gif

Configuring Rules for Pages with Session Tracking

See Also:

"Session Tracking" for an overview  

You can configure cacheability rules for pages that use session ID information, enabling Oracle Web Cache to serve the same page for multiple user sessions.

Here's how caching of session tracking pages works: When a user first accesses a Web site that uses session IDs, the application Web server assigns a unique session ID to the user. Session IDs are contained within a cookie or embedded in the URL as a parameter. If you configure Oracle Web Cache to cache the pages that use a session ID, subsequent requests that pass the cookie or embedded URL parameter are served from the cache.


Note:

Oracle Web Cache ignores the values of session cookies. The response from the application Web server is cached, even if the response session cookie value does not match the request session cookie value. If you do not want the response cached when there is a value mismatch, then modify the application to instead send a non-200 status code as the response. 


To create caching rules for pages that support session tracking:

  1. Start Oracle Web Cache Manager.

    See Also:

    "Starting Oracle Web Cache Manager" 

  2. In the navigator pane, select Administering Web Sites > Cacheability Rules or Session Management > Session/Personalized Attribute Related Caching Rules.

    The Session/Personalized Related Caching Rules page appears in the right pane.

  3. In the Session/Personalized Related Caching Rules page, choose Create or Add.

    The Add Session/Personalized Attribute Related Caching Rules dialog box appears.

  4. From the Please select a session/attribute list, select a session and skip to Step 6.


    Note:

    By default, Oracle Web Cache provides definitions of two session identifiers that are commonly used by components of Oracle9i Application Server. The predefined session identifiers are:

    JSESSIONID: Used for servlet session tracking. It conforms to the Java 2 Platform, Enterprise Edition (J2EE) standard. The cookie name is JSESSIONID; the embedded URL parameter is jsessionid.

    FoundationPersistentSessionID: Used by Oracle9iAS Foundation Classes for persistent session tracking. The cookie name is ESFSID. There is no embedded URL parameter. 


    If the sessions listed do not contain the definition you require, then choose Create Session/Personalized Attribute to create a new session definition. The Edit/Create Session/Personalized Attribute Definition dialog box appears. Continue to Step 5.

  5. Create a session definition in the Edit/Create Session/Personalized Attribute Definition dialog box:

    1. In the Session/Attribute field, enter an easy-to-remember unique name for the session.

    1. Enter the cookie name in the Cookie Name field and/or the embedded URL parameter in the URL Parameter field.

      If you enter both a cookie name and an embedded URL parameter, keep in mind that both must be used to support the same session. If they support different sessions, create separate session definitions. You can specify up to 20 definitions for each page.


      Note:

      When a session cookie expires, the browser removes the cookie and subsequent requests for the document are directed to the application Web server. To avoid pages being served past the browser session expiration time, ensure that the session cookie expires before the application Web server expires the browser session.  


    2. In the Default Value (Optional) field, enter a default string that Oracle Web Cache will use for the cookie or embedded URL parameter value. Oracle Web Cache uses the default string for those requests without the cookie or parameter information. For these requests, Oracle Web Cache substitutes the personalized attribute or session ID information with the default string. The default string defaults to default.

    3. Optionally, in the Comment field, enter a description of the definition.

    4. Choose Submit.

  6. For the prompt 1. Cache documents whose requests contain this session? in the Add Session Related Caching Rule dialog box, select either YES or NO:

    • Select YES to cache versions of documents that use the session information associated with the selected session.

    • Select NO to not cache versions of documents that use the session information.

  7. For the prompt 2. Cache documents whose requests do not contain this session?, select either YES or NO:

    • Select YES to cache versions of documents that do not use the session information. This enables Oracle Web Cache to serve documents from the cache for Web browser requests without the session information.

    • Select NO to not cache versions of documents that do not use the session information.

  8. If you answered YES to the prompts described in Steps 6 and 7, for the prompt 3. Can the document whose request doesn't contain this attribute be derived from the document whose request does contain this attribute by using the default value of the attribute?, select either YES or NO:

    • Select YES to cache one version of the document. For those requests without a session cookie or embedded URL parameter, a default value is used.

    • Select NO to cache two different versions of the document. Oracle Web Cache serves one version to those requests that support session cookie or the embedded parameter and serves the other version to those requests that do not support the session cookie or embedded parameter.

  9. In the Add Session/Personalized Attribute Related Caching Rule dialog box, choose Submit.

  10. Associate the session-tracking rule with URLs:

    1. In the Session/Personalized Attribute Related Caching Rules page, select the newly-created rule, and then choose Change Selector Association.

      The Change Policy-Selector Association dialog box appears.

    1. Select a selector from the right list, and then choose the Make Association button.

      The selector moves to the left list and the dialog box closes. Proceed to Step 11.

      If the selector you require does not exist, then create a cacheability rule for the pages the support session tracking, as described in "Configuring Cacheability Rules". In Step 10 of the procedure, select Apply the following and a rule in the Session/Personalized Attribute Related Caching row of the Edit/Create Cacheability Rule dialog box.

  11. Repeat Steps 3 through 10 for each rule.

  12. Apply changes and restart Oracle Web Cache:

    1. In the Oracle Web Cache Manager main window, choose Apply Changes.

    1. In the navigator pane, select Administering Oracle Web Cache > Web Cache Operations.

      The Oracle Web Cache Operations page appears in the right pane.

    2. In the Oracle Web Cache Operations page, choose Stop and then Start to restart Oracle Web Cache.

      Tip:

      Some Web sites require users to have sessions while surfing most pages. If you want to preserve the session requirement, then you need to create a session-related caching rule for those pages. This way, a request without a session will always be served by the application Web server.

      For some popular site entry pages, such as "/", that typically require session establishment, session establishment effectively makes the page non-cacheable to all new users without a session. To cache these pages while preserving session establishment, make the following minor modifications to your application:

      1. Create a blank page for the entry URL, such as "/", that redirects to the real entry page.

      2. Make the application Web server create a session when the blank page is requested without session.

      3. Create a cacheability rule for the real entry page and the blank page, as described in "Configuring Cacheability Rules".

      In Step 10 of the procedure, select Apply the following and then select a session-related caching rule with a value of cache with session, no cache w/o session in the Session/Personalized Attribute Related Caching Rules row of the Edit/Create Cacheability Rule dialog box.

      In this way all initial user requests to the entry URL will first hit the blank page, which requires minimal resources to generate, and receive the response and session establishment from the application Web server. Subsequent redirected requests to the more expensive entry page will carry the session, enabling it to be served out of the cache. 

Configuring Pages for Content Assembly and Partial Page Caching

See Also:

"Content Assembly and Partial Page Caching" for an overview of partial page caching 

This section describes how to enable dynamic assembly of Web pages of HTML fragments and create rules for the cacheable and non-cacheable page fragments. It contains the following topics:

Enabling Partial Page Caching

To enable partial page caching:

  1. Create a template page and HTML fragments to include.

  2. Configure the template page that the end user will request as follows:

    1. Use ESI markup tags in the template to fetch and include the HTML fragments.


      Important:

      ESI tags cannot be used on a page that contains <!-- WEBCACHETAG--> and<!-- WEBCACHEEND--> tags. If you require simple personalization and are using ESI, see "Using ESI for Simple Personalization"


    1. In the template page, use an HTTP Surrogate-Control: content="ESI/1.0" header in the HTTP response message:

      Surrogate-Control: max-age=30+60, content="ESI/1.0"
      

    2. Create a cacheability rule for the template page, as described in "Configuring Cacheability Rules".

      In Step 9 of the procedure, select Yes or No to enable or disable other client caches to process ESI tags.

  3. If the HTML fragments use ESI markup tags, use an HTTP Surrogate-Control: content="ESI/1.0" header in the HTTP response message.

    See Also:

    "Configuring Cacheability Attributes in Response Headers" 

  4. Determine the cacheability of the HTML fragments, and then create cacheability rules for them.

    See Also:

    "Configuring Cacheability Rules" 

    Specify rules that cache the static HTML fragments and do not cache the truly dynamic fragments that require application Web server and database server generation.

Using ESI for Simple Personalization

You can use variable expressions to achieve the same substitution as personalized attribute and session-encoded URLs. Oracle Corporation recommends using ESI for simple personalization when you are utilizing other ESI features, otherwise continue to use the methods described in "Configuring Rules for Pages with Simple Personalization".

For example, the following HTML excerpt uses the <!-- WEBCACHETAG--> and<!-- WEBCACHEEND--> tags to substitute a user's name based on the value the browser passes with UserName cookie. In addition, the session information contained within the sessionID cookie is used to replace session information for one user with another user.

Welcome <!-- WEBCACHETAG="UserName" -->John<!--WEBCACHEEND -->!
Here is a <a href="/jsp/myPage.jsp?sessionID=13001">link</a>.

The same effect is achieved with the following ESI markup:

<esi:vars>
 Welcome $(HTTP_COOKIE{'username'})!
 Here is a <a href="/jsp/myPage.jsp?sessionID=$(QUERY_
STRING{'sessionid'})">link</a>.
</esi:vars>        

The <esi:vars> tag enables you to use an ESI environment variable outside of an ESI tag. Variables can also be used with other ESI tags.

See Also:

"Variable Expressions"

"ESI vars Tag" 

Examples of ESI Usage

This section provides examples of ESI usage in the following topics:

Example Portal Site Implementation

Figure 6-8 shows a portal site page, http://www.company.com/servlets/esi?username=jesse&userID=004&zipcode=94108&SportsSelection=golf, for a registered user named Jesse.

Figure 6-8 Portal Site Page


Text description of cache8.gif follows
Text description of the illustration cache8.gif

An esi Java servlet reads in the portal.esi file, which is a template page comprised of ESI markup tags, and processes the ESI tags to display the correct stock, news, and weather output for user Jesse. The servlet also sets the Surrogate-Control: content="ESI/1.0" header to enable ESI processing.

Without ESI, the servlet output would have been a pure HTML file. Because of its dynamic content, including a rotating banner ad, a personalized greeting, stock quotes, regional weather, and news content, this page would not be cacheable. For example, the src attribute of the <img> tag for the banner ad changes for each request, making it uncacheable:

<img src="http://www.companyad.com/adbanner/item11934502">

On the other hand, with ESI markup tags, Oracle Web Cache is able to assemble and cache most of the content. The rest of this section examines the ESI markup used in portal.esi and shows how ESI increases overall cacheability. Note that much of the HTML formatting has been removed for the sake of clarity.

Figure 6-9 shows the markup for the rotating ad banner and the personalized greeting Welcome, jesse!. The banner relies on alternate processing with the <esi:try> tag. If the servlet cannot run AdBanner, then a link to www.oracle.com appears in the banner's place. The personalized greeting is achieved by the <esi:vars> tag, which bases the greeting on the username parameter embedded in the URL. username is the registered user's name. This markup enables the banner and personalized greeting to be included in the cacheable template page.

Figure 6-9 portal.esi Example: Rotating Banner and Personalized Greeting

<table width="100%" cellpadding="2" cellspacing="0" border="0" align="Center" 
height="98">
  <tbody> 
....
<!-- Rotating Ad Banner -->
    <esi:try>
    <esi:attempt> 
        <esi:comment text="Include an ad banner <img> html tag"/>
        <esi:include src="/servlets/AdBanner"/>
    </esi:attempt>
    <esi:except>
        <esi:comment text="Just write some HTML instead"/> 
        <a href=www.oracle.com>www.oracle.com</a>
    </esi:except>
    </esi:try>
....
<!-- Personalized Greeting -->    
    <p>
    <esi:vars>Welcome, $(QUERY_STRING{username})!</esi:vars>
    </p>
....
  </tbody> 
</table>
<br>
....

As shown in Figure 6-10, the response to the included image fragment for the banner is not cacheable. The first time a user requests this page, Oracle Web Cache sends the request to the application Web server to generate the banner. On the application Web server, AdBanner generates the banner for the request.

Figure 6-10 portal.esi Example: Rotating Banner and Personalized Greeting Output

<table width="100%" cellpadding="2" cellspacing="0" border="0" align="Center" 
height="98">
  <tbody> 
....
<!-- Rotating Ad Banner -->
<a href="www.companyad.com/redirect?item=11934502">
<img src="http://www.companyad.com/adbanner/item11934502"></a>
....
<!-- Personalized Greeting -->    
    <p>
    Welcome, jesse!
    </p>

  </tbody> 
</table>
<br>
....

As shown in Figure 6-11, the next time the user reloads the page, AdBanner generates another banner for the request.

Figure 6-11 portal.esi Example: Rotating Banner and Personalized Greeting Reload

<table width="100%" cellpadding="2" cellspacing="0" border="0" align="Center" 
height="98">
  <tbody> 
....
<!-- Rotating Ad Banner -->
<a href="www.companyad.com/redirect?item=123456602">
<img src="http://www.companyad.com/adbanner/item123456602"></a>
....
<!-- Personalized Greeting -->    
    <p>
    Welcome, jesse!
    </p>
  </tbody> 
</table>
<br>
....

By separating the generation of the included image fragment response from the template page, Oracle Web Cache is able to cache the template and integrate the dynamic ad banner into the template.

The markup for My Stocks, World Markets, and Movers is depicted in Figure 6-12. My Stocks includes a fragment named PersonalizedStockSelection. The displayed stocks are based on the userID parameter encoded in the URL. userID is the registered user's unique ID. The World Markets and Movers sections rely on alternate processing with the <esi:try> tag. The <esi:try> tag first attempts to include data from external sites. If the content cannot be fetched, then the message Sorry, can't display indexes displays.

Figure 6-12 portal.esi Example: My Stocks, World Markets, and Movers Sections

....
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tbody>
  <tr> 
    <td>
    My Stocks
    </td>
    <td>
    World Markets
    </td>
    <td>
    Movers
    </td>
  </tr>
  <tr>
    <td width="26%">
    <!-- Personalized Stock Content -->
    <esi:include src="/servlets/PersonalizedStockSelection?userID=$(QUERY_
STRING{userID})" />   
</td>
<td valign="Top" width="23%">

<!-- External World Market Content -->
<esi:try>
  <esi:attempt>
    <esi:include 
src="/servlets/Proxy?url=http://www.service.com/WorldMarketIndex">
  </esi:attempt>
  <esi:except>
    Sorry, can't display indexes
  </esi:except>
</esi:try>
</td>

<!-- External Movers Content -->
<td valign="Top" width="51%">
<esi:try>
  <esi:attempt>
    <esi:include src="/servlets/Proxy?url=http://www.service.com/Movers">
  </esi:attempt>
  <esi:except>
   Sorry, can't display second set of indices
  </esi:except>
</esi:try>
</td>
</tr>
</tbody> 
</table>
....

The markup for the included fragment PersonalizedStockSelection is depicted in Figure 6-13. It includes fragments for three stock quotes: IBM, ORCL, and YHO.

Figure 6-13 portal.esi Example: PersonalizedStockSelection Fragment for jesse


<table width="160" cellspacing="0" cellpadding="0" border="0">
  <tbody>
  <tr>
    <br>
    <esi:include src="Quote?symbol=IBM"/>
    <br>
    <esi:include src="Quote?symbol=ORCL"/>
    <br>
    <esi:include src="Quote?symbol=YHO"/>
    <br>
  </tr>
  </tbody>
</table>

Because the output is different for each user, the PersonalizedStockSelection fragment is not cacheable. However, the response to each of the included quotes is cacheable, enabling stock quotes to be shared by multiple users. Even when many users share quotes, only one browser reload is needed when the quotes are updated. For example, the PersonalizedStockSelection fragment for another user named Scott is depicted in Figure 6-14. It includes fragments for three stock quotes: IBM, ORCL, and SCO. As already described, IBM and ORCL are also shared by Jesse. If Jesse reloads the page first and caches the quotes, then the IBM and ORCL quotes for Scott are automatically refreshed.

Figure 6-14 portal.esi Example: PersonalizedStockSelection Fragment for scott


<table width="160" cellspacing="0" cellpadding="0" border="0">
  <tbody>
  <tr>
    <br>
    <esi:include src="Quote?symbol=IBM"/>
    <br>
    <esi:include src="Quote?symbol=ORCL"/>
    <br>
    <esi:include src="Quote?symbol=SCO"/>
    <br>
  </tr>
  </tbody>
</table>

Figure 6-15 shows the markup for Latest Headlines, Weather, and Sports.

Latest Headlines displays the content based on the user's NewsSelection category, internet or finance, by using conditional processing with the <esi:choose> tag. Because the URL of the Company Portal page in Figure 6-8 did not embed the NewsSelection parameter, the output includes the top news stories, /News?type=Top&topic=TopNews.

Weather uses the <esi:vars> tag to display the current weather conditions based on the registered user's zip code. Because Jesse entered in zipcode=94108 in the URL, the output includes weather conditions for San Francisco, California.

Sports displays the sports content based on the user's SportsSelection category: golf, soccer, football, baseball, or basketball. Because the URL for user Jesse embeds SportsSelection=golf, the output includes headlines relating to golf, /News?type=Top&topic=GolfNews.

Figure 6-15 portal.esi Example: Headline News, Weather, and Sports Sections

....
<!-- News, Weather, and Sports Content -->
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tbody> 
  <tr> 
    <td>
    Latest Headlines
    </td>
    <td>
    Weather
    </td>
    <td>
    Sports
    </td>
  </tr>
  <tr> 
    <td>
    <!-- News Content -->
    <!-- Use the esi include tag so that different portal users can share the 
included news HTML snippet -->   
     <esi:choose>
       <esi:when test="$(QUERY_STRING{NewsSelection}) == 'internet'">
         <esi:include src="/News?type=Top&topic=TopTechNews" 
onerror="continue"/>
       </esi:when>
       <esi:when test="$(QUERY_STRING{NewsSelection}) == 'finance'">
         <esi:include src="/News?type=Top&topic=TopFinanceNews" 
onerror="continue"/>
       </esi:when>
       <esi:otherwise>
         <esi:include src="/News?type=Top&topic=TopNews" onerror="continue"/>
       </esi:otherwise>
     </esi:choose>
    </td>
    <td> 
    <!-- Weather -->
     <esi:vars>
       <img src="http://www.SomeWeather.com/servlets/GetWeather?zipcode=$(QUERY_
STRING{zipcode})">
     </esi:vars>
    <td>
    <!-- Sports -->
    <!-- Use the esi include tag so that different portal users can share the 
included sports HTML snippet -->    
     <esi:choose>
       <esi:when test="$(QUERY_STRING{SportsSelection}) == 'golf'">
         <esi:include src="/News?type=Top&topic=GolfNews" onerror="continue"/>
       </esi:when>
       <esi:when test="$(QUERY_STRING{SportsSelection}) == 'soccer'">
         <esi:include src="/News?type=Top&topic=SoccerNews" onerror="continue"/>
       </esi:when>
       <esi:when test="$(QUERY_STRING{SportsSelection}) == 'football'">
        <esi:include src="/News?type=Top&topic=FootballNews" 
onerror="continue"/>
       </esi:when>
       <esi:when test="$(QUERY_STRING{SportsSelection}) == 'baseball'">
         <esi:include src="/News?type=Top&topic=BaseballNews" 
onerror="continue"/>
       </esi:when>
        <esi:when test="$(QUERY_STRING{SportsSelection}) == 'basketball'">
          <esi:include src="/News?type=Top&topic=BasketballNews" 
onerror="continue"/>
       </esi:when>
    <esi:otherwise>
    <esi:include src="/News?type=Top&topic=SportsNews" onerror="continue"/>
       </esi:otherwise>
       </esi:choose>
    </td>
    </tr>
  </tbody>
  </table>

Example of Simple Personalization with Variable Expressions

As described in Step 3 of "Configuring Rules for Pages with Simple Personalization", the <!-- WEBCACHETAG--> and <!-- WEBCACHEEND--> tags can be used between other HTML tag pairs, but not within an HTML tag. However, ESI variables can be used within an HTML tag.

For example, consider Figure 6-16. Its HTML code uses PL/SQL for an HTML form with a text box in it.

Figure 6-16 PL/SQL Code without Personalization

htp.p('<form action="test" method="GET">');
htp.p('<table border="0" >
      <tr>
      <td><input type="text" name="p_name" size="8" value="'||p_name||'"></td>
      </tr>
      <tr>
      <td><input type="submit" value="Search"></td>
      </tr>
</table>');

Figure 6-17 shows how the $HTTP_COOKIE variable is used with the <esi:vars> tag to replace the value of p_name with the user's name.

Figure 6-17 PL/SQL Code with Personalization through ESI

htp.p('<form action="test" method="GET">'); 
htp.p('<table border="0" > 

    <tr><esi:vars> 
         <td><input type="text" name="p_name" size="8" value="$(HTTP_
COOKIE{'p_name'}"></td> 
         </tr></esi:vars> 
         <tr> 
         <td><input type="submit" value="Search"></td> 
         </tr> 
  </table>'); 

Configuring Cacheability Attributes in Response Headers

In addition to creating cacheability rules with Oracle Web Cache Manager interface, application developers can choose to store some of the cacheability attributes in the header of an HTTP response message. This feature enables the application Web server to override the settings configured through the Oracle Web Cache Manager interface, as well as allowing other third-party caches to use Oracle Web Cache cacheability attributes.

To enable this feature, configure the HTTP response with the Surrogate-Control response-header field as follows:

Surrogate-Control:control_directive,control_directive,...

Table 6-4 describes the supported control directives.

Table 6-4 Surrogate-Control Control Directives

Control Directive  Description 

no-store 

Specify for Oracle Web Cache not to cache the document. 

no-store-remote 

Specify to now allow other ESI-compliant caches, such as third-party Content Delivery Network (CDN), to cache the document.

The no-store-remote directive has similar semantics to the no-store directive, except that it is only be honored by "remote" caches. Generally, this means those caches that are more than one or two hops from the application Web server, such as caches in a Content Delivery Network (CDN).

This directive is especially useful if you want to cache volatile content locally, where invalidation propagation is immediate, but not in a distributed network of upstream ESI processors, where invalidation may take several minutes. 

max-age 

Specify to enable Oracle Web Cache to cache the document.

Specify the time, in seconds, to expire the document. Optionally, specify the time, in seconds, to remove the document from the cache after the expiration time. Use the following format:

max-age=expiration_time [+ removal_time]

The default removal time is 0 seconds. 

content 

Specify what kind of processing is required:

  • "ESI/1.0" to process ESI tags for content assembly and partial page caching

  • "webcache/1.0" to process the <!-- WEBCACHETAG--> and <!-- WEBCACHEEND--> tags for personalized attributes and session-encoded URLs

 

Usage Notes

Example Usage

In the following example, the Surrogate-Control response-header field specifies that the document is to expire in 30 seconds and be removed 60 seconds after expiration. It also specifies that the document contains ESI tags that require processing:

Surrogate-Control: max-age=30+60, content="ESI/1.0"

In the following example, the Surrogate-Control response-header field specifies that the document is not to be cached:

Surrogate-Control: no-store

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

All Rights Reserved.
Go To Documentation Library
Library
Go To Product List
Services
Go To Table Of Contents
Contents
Go To Index
Index