Configuring Oracle Web Cache for Caching a Java EE Application

 

Purpose

This tutorial demonstrates the tasks in administering Oracle Web Cache.

Time to Complete

Approximately 1hour.

Overview

Oracle Web Cache is a content acceleration and assembly solution designed to scale the middle-tier infrastructure and improve end-user experience. By caching the frequently requested Web content in memory, Oracle Web Cache effectively offloads application servers and database from repeatedly processing those requests. The picture below shows the basic architecture of Oracle Web Cache.

With Oracle Web Cache, you can cache personalized Web pages that you otherwise cannot cache by using legacy caching products. You can even cache parts of a page as fragments by using the Edge Side Includes (ESI)* specification. Oracle Web Cache provides a flexible invalidation mechanism to ensure consistency in content between the origin servers and the cache. To scale and increase availability of your Web sites, you can configure Oracle Web Cache to perform back-end load balancing, fail over, and native clustering. Oracle Web Cache also supports WinZip or GZIP for compressing content (both cached and noncached content) and secure sockets layer (SSL) for handling encrypted content. With Oracle Web Cache, Web sites can now serve content faster and to more customers by using fewer computing resources than ever before.

The benefits of Oracle Web Cache can be measured by improvements in the following areas:

* ESI is a simple markup language used to define components of a Web page for dynamic assembly and delivery of Web applications at the edge of the Internet. More information about ESI is available at http://otn.oracle.com/products/ias/web_cache.

Software and Hardware Requirements (Optional)

The following is a list of software requirements:

Item Specification
Processor Type Intel Xeon or Pentium IV
Processor Speed 2.4 GHz or higher
Number of Processors 1 or more (if required)
Memory 2 GB
Hard Disk Space 20 GB (initial size)
Operating System RedHat Enterprise Linux 4 Update 5

Prerequisites

Before starting this tutorial, you should:

.

Have an instance of Oracle WebLogic Server 10.3.

.

Have configured a domain.

.

Download and unzip the webapp.zip file on your machine. Deploy the WebAppWar.war file to the application Web server.

Configuring port configuration for Oracle Web Cache with OPMN

Oracle Web Cache uses HTTP or HTTPS listening port to receive requests. You can also add listening ports, if necessary. For example, it may be necessary to add a listening port to assign Oracle Web Cache a port that an origin server was previously listening on.

In addition to a listening port, Oracle Web Cache also receives requests for the admin server process, invalidation, and statistics monitoring requests on specific HTTP or HTTPS listening ports.

Verifying port configuration for Oracle Web Cache


.

To determine ports in use by Oracle Web Cache with OPMN, execute the following commands:

Navigate to your ORACLE_INSTANCE/bin directory and execute opmnctl status -l command. For example:

$cd /u01/app/oracle/product/fmw/11.1.1.1/as_1/opmn/bin/opmnctl status -l

In this example:

Port 7785 is the HTTP listening port for Oracle Web Cache, represented by http_
listen.
Port 7786 is the HTTP listening port for the admin server process, represented by
WebCache-admin
Port 7787 is the HTTP listening port for statistics monitoring requests, represented
by http_stat.
Port 7788 is the HTTP listening port for invalidation requests, represented by
http_invalidation.
Port 7789 is the HTTP listening port for Oracle Web Cache, represented by https_
listen.

 

Verifying port configuration for Oracle Web Cache with Fusion Middleware Control


.

Enter the following URL to display Fusion Middleware Control.

http://<hostname>.<domain>:<port>/em

Enter the Oracle Fusion Middleware administrator user name and password. Click Login.

 

 

.

From the navigation pane, expand the farm and then the Web Tier installation type, and select Oracle Web Cache component. From the Web Cache menu, select Port Usage.


.

The Ports Usage page displays.

In this example:

Port 7786 is the HTTP listening port for the admin server process, represented by
WebCache-admin
Port 7787 is the HTTP listening port for statistics monitoring requests, represented
by http_stat.
Port 7788 is the HTTP listening port for invalidation requests, represented by
http_invalidation.
Port 7789 is the HTTP listening port for Oracle Web Cache, represented by https_
listen.
Port 7785 is the HTTP listening port for Oracle Web Cache, represented by http_
listen.

 

Adding an Oracle Web Cache listening port

.

You can add listening ports, if necessary. For example, it may be necessary to add listening port to assign Oracle Web cache a port that an origin server was previously listening on. To add an HTTP listening port:

From the Web Cache menu, select Administration > Ports Configuration.

 

 

.

The ports configuration page displays. Click Create. The Create Port page appears.


.

From the Port Type list, select NORM. In the IP Address field, select ANY to represent any IP address. In the Port field, enter the listening port from which Oracle Web Cache receives client requests for the Web site. Ensure that this port number is not already in use. For example, enter 7890.

Click OK.

 

.

Click Web Cache > Control > Restart to restart Oracle Web Cache.

Click Restart to confirm.

Click Close when the restart operation completes successfully.

 

Specify Site definitions

.

Oracle Web Cache caches and assembles dynamic content for one or more Web sites. When Oracle Web Cache receives a browser request for a document, it determines the destination site by using one of the following elements:

  • Host request-header value from the request
  • Host portion of the requested URL

Oracle Web Cache then looks up the configured site settings and mappings to determine whether the site is supported, and the application Web servers or proxy servers and caching rules for the site.

To configure a site definition, navigate to the Oracle Web Cache Home page in Fusion Middleware Control. From the Web Cache menu, select Administration > Sites.
.

 

 

.

The Sites page is displayed. From the Site Definitions section, click Create to add a new site.


.

Enter the following information to configure Oracle Web Cache with information about the named Web site:

Parameter Description
Host Enter the host name of the site, such as myserver.us.oracle.com. Do not use the wildcard * to represent multiple sites.
Port Enter the port number from which the Web site is listening for incoming HTTP or HTTPS requests. The port number should be of the port used in browser requests.
URL Prefix Enter the path prefix of the URLs to distinguish this site from another site that shares the same host name. Do not include the file name or embedded URL parameters in the prefix and make sure that the prefix starts with “/”. When defining a site definition, you can specify a URL path prefix for those sites that share the same host name.

Click OK.

Oracle Web Cache resolves an incoming request first to a site definition, and then to the first matching site-to-origin server mapping.

.

Click Apply and then restart Oracle Web Cache from Web Cache > Control > Restart.

Click Restart to confirm.

Click Close to close the Confirmation window.

 

Map site definitions to Origin Servers

.

Configure Oracle Web Cache with the application Web servers or proxy servers to
which it sends cache misses. Typically, Oracle Web Cache uses application Web servers
for internal sites and proxy servers for external sites outside a firewall.
If Oracle HTTP Server was installed, the installation process creates a default origin
server based on the host name and listening port of Oracle HTTP Server.
Oracle Web Cache only forwards requests to a configured origin server if the origin
server is mapped to a Web site.

From the Web Cache menu, select Administration and then Sites.

 

.

The Sites page displays. From the Site-to-Server Mapping section, click Create.


.

Enter the following information for the Origin Server to enable it to send Oracle Web Cache requests:

Parameter Description
Host Pattern Enter the site pattern, such as www.company.com.
Port Pattern Enter the HTTP or HTTPS port number for the Web site from which Oracle Web Cache is listening for incoming requests.

Select the Web Server (edrsr15p1.us.oracle.com) to which the additional Web Cache port should be mapped. The Web Server is now listed under Selected Origin Servers.

In the Origin Servers section, select the origin server. Click Move.

Click OK.

Oracle Web Cache resolves an incoming request first to a site definition, and then to the first matching site-to-origin server mapping.

.

Click Apply.

Restart Oracle Web Cache from Web Cache menu > Control > Restart.

 

Adding Caching Rules and Compression

If you want to cache your document by using Oracle Web Cache, then you must establish a caching policy. The caching policy can be embedded within the application specified by the application developers (for example, using Edge Side Includes tags [www.esi.org] or surrogate-control headers) or explicitly set as a caching rule in Oracle Enterprise Manager 10g Application Server Control Console.

.

Open a browser window and enter the following URL to access the application:
http://edrsr15p1.us.oracle.com:7890/cntroot/login.jsp

Enter some value and browse through the application to generate some data for the Popular Requests page.

You can check whether the pages are cached or not by visiting the Popular Requests page.

 

.

Navigate back to Oracle Fusion Middleware Control and access the Oracle Web Cache administration page.

You can view a list of the most popular requests and a list of the contents of the cache as well as requests that were not cached from the Popular Requests page. From the Web Cache menu, select Monitoring and then Popular Requests. The Popular Requests page appears.


.

You see No in the Cached? column.

.

Click Web Cache > Administration > Caching Rules to create a caching rule.

 

.

On the Caching Rules page, determine first whether the rule for the object is for a specific site or global to all sites. In this example, select your site - edrsr15p1.us.oracle.com:7890 to create a site-specific rule. Click Change the Site to confirm the change.

 

.

Click Create to create a rule.

.

Enter values or select from the drop-down list to match the values given below:

Name: Any name that you want
Description: Any description that you want
Enabled: Select
Site: edrsr15p1.us.oracle.com:7890
Match URL By: File Extension servlet
Cache: Select
Expiration: Expire 3600 seconds after cache entry. Remove 360 seconds after expiration.
Compress: Select

 

.

Under HTTP Methods, make sure that the GET and GET with query string check boxes are selected. Click OK.

Oracle Web Cache uses regular expression to represent the URL. In this example, you are instructing Oracle Web Cache to cache all Servlet pages.

By enabling compression, you are instructing Oracle Web Cache to compress the pages . Oracle Web Cache automatically disables compression for some common file types which are known to be already compressed. Oracle recommends not compressing content for these file type, including GIF, JPEG, and PNG images, or files that are already compressed with utilities like WinZip or GZIP. Compressing these files incurs additional overhead without gaining any compression benefit..

You are setting the cached documents to expire every 300 seconds (5 minutes). You learn how to manually invalidate a certain document (regardless of whether you have set up an expiration policy or not) later in this tutorial.

 

.

The new caching rules should appear in the Rules table. You have completed the basic configuration of Oracle Web Cache. Click Apply. Navigate to Web Cache > Control > Restart to restart the Web Cache. Click Restart to confirm.

Click Close to close the confirmation window.

 

Accessing the Web Application Through Oracle Web Cache

Oracle Web Cache is transparent to the end user. Instead of going to the listen port of the application server, the client sends requests to the listen port for Oracle Web Cache.

.

Open a new browser window and enter the following URL:

http://localhost:7890/cntroot/cntroot/login.jsp

In this tutorial, Oracle Web Cache is configured to listen on port 7890 for HTTP requests and Oracle HTTP Server (OHS) is configured to listen on port 7777. When you access the application through Oracle Web Cache, you should see the same page that you see when you access it through OHS directly. You do not see any difference because Oracle Web Cache is transparent to the end user.

 

.

Click the links on the Web site. When you first request the page, Oracle Web Cache forwards the request back to the origin server and then caches the response from the origin server. The next time you request the same page, Oracle Web Cache serves it from its cache.


Verifying Cached Content

.

Navigate back to Oracle Fusion Middleware Control and access the Oracle Web Cache administration page.

You can view a list of the most popular requests and a list of the contents of the cache as well as requests that were not cached from the Popular Requests page. From the Web Cache menu, select Monitoring and then Popular Requests. The Popular Requests page appears.

.

The Popular Requests page displays the most popular requests received by Oracle Web Cache, regardless of the caching of the pages. Notice that the JSP pages are cached and compressed. You may need to click Refresh to refresh the page.

Invalidating All Content

Oracle Web Cache Manager provides an easy-to-use interface for invalidating cached objects. The advantage of using this interface is that the administrator is isolated from the intricacies of the HTTP and XML formats, and consequently, there is less chance for error. The administrator need only specify which objects to invalidate and how how quickly those objects should be invalidated.

Oracle Web Cache Manager enables you to send either basic invalidation request for invalidation one object, or an advanced invalidation request for multiple
objects.

Complete the following steps to send a basic invalidation request using Oracle Web Cache Manager.

.

Enter the following URL to access Oracle Web Cache Manager. Enter the username and password. For example, administrator and the associated password. Click OK.

 


.

In the navigator frame, select Operations > Basic Content Invalidation. The Basic Content Invalidation page appears in the right pane.


.

From the For Cache list, select a cache. Select Remove all cached objects in the Search Criteria section to remove all objects from the cache.

Oracle Web Cache offers flexible invalidation mechanisms. One method is to specify the exact object (or objects) for precise invalidation. Besides Oracle Enterprise Manager interface, Oracle Web Cache accepts XML-based invalidation messages at its invalidation port. Telnet or database triggers can be used to generate the invalidation messages.


.

Check that the Remove immediately option is selected, and click Submit.

If you select the second option, Oracle Web Cache marks objects as invalid and then refreshes them based on origin server capacity. Enter the maximum time in which the objects can reside in the cache. When you select this option, Oracle Web Cache applies heuristics to determine when is best time to no longer serve the document.

Optionally, you can preview the list of objects to be invalidated to ensure that you are removing only the objects you want to remove by selecting "Preview list of objects that match invalidation criteria".


.

Oracle Web Cache processes the invalidation request, and returns the Cache Cleanup Result dialog box which shows the invalidation status. Click OK.


.

Check the Popular Requests page again. Click the Performance tab, and then click Popular Requests. From the Web Cache menu, select Monitoring and then Popular Requests. The Popular Requests page appears.

Summary

In this tutorial, you have learned how to:

Resources