How does caching work in Oracle9iAS Portal?

Portal pages are not defined as static HTML files—they are generated from content that is either stored in a database or retrieved from a Web provider. Dynamically assembling a page from multiple sources can be a very expensive operation, in terms of both CPU consumption and network latency. Therefore Oracle9iAS Portal uses sophisticated caching mechanisms to minimize database and provider calls. Page metadata, portlet content, and rendered pages are all cached to achieve a high degree of scalability and performance while still enabling dynamic personalization and protecting the security of portal content.

This topic is divided into the following sections:

| Caching types | User and system level caching | Page caching | Portlet caching | Document and image caching | Event caching | Login metadata caching |

Caching types

Three types of caching are used for portal content:

Validation-based and invalidation-based caching both ensure that users are seeing the most up-to-date information. These types of caching are most appropriate for content that can change frequently or on a random basis and for which the cost of the validity check or sending the invalidation message is low. For example, a document can be quickly checked for changes by comparing time-stamps between the cache and the portal.

Expiry-based caching, on the other hand, pins a cache entry to the cache for a specified period of time. Expiry-based caching can result in better performance, since certain checks and refresh operations are eliminated; however, users may be seeing stale content if the underlying data changes before the expiry-based cache entry expires. Expiry-based caching is most appropriate when content is not time-sensitive and the cost of validating or invalidating the content is high. For example, use expiry-based caching where an expensive query is required to see if a new product has been added to a catalog, yet the catalog is updated infrequently and users don't need to see the updated immediately.

User and system level caching

Oracle9iAS Portal supports user customizations of pages and portlets. It also filters out portlets and content items that a user is not authorized to view. Because of these customizations and security features, the view of a page can vary from one user to the next. Portal's caching is designed to allow content to vary on a per-user basis, even though the physical URL being cached is the same across users.

A portlet developer can specify either of two levels of caching for a portlet:

Note: Web portlets can be cached at the system, user, and session levels. Database portlets can be cached at the system and user levels only.

Page caching

Pages (including both the page definition and the assembled page) are always cached at the user level. Page definitions in Web Cache are cached on a per-session basis. When a session ends (i.e., when the user logs out or closes his or her browser), the Web Cache entry is no longer accessible. However, the next time the user logs in, the Web Cache entry can be recreated from the cached user level page definition in the Portal Cache.

Page caching works identically for normal pages and for Java Server Pages that have been loaded into the portal (internal JSPs). The portal caching mechanisms do not cache external JSPs—JSPs that contain portlets but that run externally to the portal; however, caching is managed by the portal for the portlets contained on external JSPs. For more information about JSPs, see Working with Java Server Pages.

The following table summarizes the recommended page caching options for different types of content:

Content

Recommended page caching option

Static (e.g., items that are manually updated).

Cache page definition and content with a long retention period. Changes to the page definition (including modifications to items) will force a refresh, even if the page has not expired.

Portlets with expiry-based caching.

Cache page definition and content. Retention period should be less than or equal to the shortest portlet retention period.

Portlets with invalidation- or validation-based caching where some stale content is acceptable.

Cache page definition and content with a short retention period.

Portlets with invalidation- or validation-based caching where content must always be up-to-date.

Cache page definition only to ensure that portlet validity is checked when the page is assembled.

Dynamic items (PL/SQL, URL) where some stale content is acceptable.

Cache page definition and content with a short retention period.

Dynamic items where content must always be up-to-date.

Don't cache. It's a good idea to put this content on pages that are not frequently accessed, or use portlets instead of items and choose Cache page definition only.

Portlet caching

Like pages, portlets can use invalidation-based, validation-based, or expiry-based caching. Database portlets can also use a combination of invalidation- and validation-based caching. All types of caching function the same as for pages, with the following differences:

The portlet developer specifies the type of caching that is used through the APIs of the Portal Developer Kit (PDK), which can be found on Oracle Technology Network. The following table summarizes the recommended portlet caching options for different types of content:

Content

Recommended portlet caching option

Static, infrequently updated, shared by all users (e.g., page banner, or company tombstone data like mission statements and office locations).

Expiry-based with long retention period. System level.

Static, periodically updated, shared by all users (e.g., company news bulletins).

Expiry-based with short retention period (depending on update frequency). System level.

Static, periodically updated, personalized (e.g., list of Favorite Web sites, customizable by users).

Invalidation-based, or combined invalidation- and validation-based. User level.

Dynamic (generated from database), does not require real-time updates, shared by all users (e.g., product catalog).

Expiry-based. System level. Choose retention period to meet business requirements for timeliness.

Dynamic, personalized, does not require real-time updates (e.g., delayed stock quotes).

Expiry-based with short retention period. User level.

Dynamic, personalized, requires real-time updates (e.g., active trouble tickets in a helpdesk portlet, real-time stock quotes).

Don't cache or use combined validation- and invalidation-based if the application can trigger an invalidation message. User level.

Use invalidation-based caching instead of expiry-based caching if your application can be modified to send invalidation messages to Web Cache when content needs to be refreshed, or if the user can manually refresh the content (e.g., by clicking a Refresh link in the portlet).

If appropriate, try to combine invalidation-based with validation-based caching (the combination is currently available for database portlets only). When these options are combined, a session based Web Cache entry can be refreshed from a user level Portal Cache entry, without having to contact the provider if the Portal Cache entry is still valid. The only drawback of combining the two types of caching is that the portlet developer must implement the PDK interfaces for both.

Document and image caching

Documents (including images) that are stored in the portal are cached in the Portal Cache using validation-based caching.

All images on a page are cached in Web Cache unless the image is for an item whose item type is based on either the Image or Imagemap item type.

Portal also makes extensive use of images in the /images directory on the middle-tier file system. When Portal is installed, a Web Cache directive is created that sets the cache lifetime of these images to 2,592,000 seconds (30 days). This directive overrides Web Cache's default "cache forever" rule for images.

Event caching

Portlets can define events, and those events (such as a button being clicked or a data value selected) can be mapped to page parameters to enable inter-portlet and inter-page communication.

Event metadata (the data that describes the behavior of an event) is cached in both Web Cache and the Portal Cache. The caching behavior for events is the same as for page definitions--a combination of invalidation-based and validation-based caching. Event definition cache entries will be invalidated when they are modified.

Login metadata caching

Providers can be passed login metadata that describes the current session so that they can track state for a Portal user. This session data is cached in Web Cache and passed to providers along with requests for portlet content.

Notes

Related topics

Changing how a page is cached
Clearing the cache
Setting the expiry time for invalidation-based caching