Configuring OracleAS Web Cache for Caching a J2EE Application
Configuring OracleAS Web Cache for Caching a J2EE Application
This tutorial describes how to cache a Web application.
Approximately 30 minutes
This tutorial covers the following topics:
Place the cursor over this icon to load and view all
the screenshots for this tutorial. (Caution: Because this action loads all screenshots
simultaneously, response time may be slow depending on your Internet connection.)
Note:
Alternatively, you can place the
cursor over each individual icon in the following steps to load and view only
the screenshot associated with that step.
Back to Topic List
|
Oracle Application Server Web Cache (OracleAS 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, OracleAS Web Cache effectively
offloads application servers and database from repeatedly processing those
requests. The picture below shows a typical deployment scenario of OracleAS
Web Cache running in a cluster mode.
|

Back to Topic List
Before starting this tutorial, you should:
| 1. |
Have two instances of Application
Server 10g Mid Tier (J2EE and Web Cache). For these OBEs, it is assumed
that both the instances are installed on the same machine. |
| 2. |
Have installed Oracle Database
10g. Make sure that you have hr
schema. |
| 2. |
Download and unzip the hrapp.zip
file on your machine. Deploy the hrapp.ear
file to the Oracle Application Server.
|
Back to Topic List
|
If you want to cache your document by using OracleAS
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.
|
| 1. |
Open a browser window, and enter the following URL to access the application:
http://localhost:7777/hrapp
Enter the following username and password to login:
Username: Guest
(case sensitive)
Password: welcome
(case sensitive)

Click the links 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.
|
| 2. |
In the browser, change the URL to http://localhost:1810/.
Note: 1810 is the default port that is automatically assigned
while installing the Oracle Application Server. However, if another instance
is already running on 1810, then the next port may be assigned during
installation.
Log in as ias_admin/<admin password you specified during install>,
and click OK.

|
| 3. |
You are accessing the Oracle Enterprise Manager 10g Application
Server Control Console. You see the Application Server Home page, which
provides a high-level overview of your application server (including status,
system resource usage, and enabled and configured components).

|
| 4. |
In the System Components table, click the Web Cache link
to navigate to the OracleAS Web Cache Home page.

|
| 5. |
Click the Performance tab, and then click Popular Requests.

|
| 6. |
You see Not Cached in the Cached column.

|
| 7. |
Click Web Cache in the breadcrumbs to go back to the Web Cache
Home page. Click the Administration tab.

Click the Rules link under Properties.

|
| 8. |
On the Rules page, 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
Site: localhost:7777
Match URL By: File Extension
jsp

|
| 9. |
Expand Show HTTP Methods and Parameters.
Under HTTP Methods, select the GET and GET with query
string check boxes.
Under Caching, select Cache and select Expires: Max Time in Cache,
5 Minutes, Refresh: Immediately from the Expiration of Cached Response
drop-down list.

Under Compression, select Compress for all browsers. Leave
other parameters as default values. Click OK.

OracleAS Web Cache uses regular expression to represent the URL. In this
example, you are instructing OracleAS Web Cache to cache all JavaServer
Pages (JSP). If you want to cache a specific page, you simply enter the
URL of the page and select URL Expression as the Expression Type.
By enabling compression, you are instructing OracleAS Web Cache to compress
the pages by using GZIP. OracleAS Web Cache sends compressed content according
to the accept-encoding field in the client request. If the client browser
does not support GZIP, OracleAS Web Cache sends the content uncompressed.
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.
|
| 10. |
The new caching rules should appear in the Rules table. You have
completed the basic configuration of OracleAS Web Cache. Click Restart
Web Cache to restart the Web Cache.

Click Yes when prompted for confirmation.


|
Back to Topic List
|
OracleAS 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 OracleAS Web Cache.
|
| 1. |
Open a new browser window, and enter the following
URL:
http://localhost:7777/hrapp
Enter the following username and password to login:
Username: Guest
(case sensitive)
Password: welcome
(case sensitive)

In this tutorial, OracleAS Web Cache is configured to listen on port
7777 for HTTP requests and OracleAS HTTP Server (OHS) is configured to
listen on port 7778. When you access the application through OracleAS
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 OracleAS Web
Cache is transparent to the end user.
|
| 2. |
Click the links on the Web site. When you first request the page, OracleAS
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, OracleAS Web Cache serves it from its cache.

|
Back to Topic List
| 1. |
Check Popular Requests again. Go back to the browser
window that is displaying the Rules page. Click Web Cache
in the breadcrumbs.

Click the Performance tab, and then click Popular Requests.

|
| 2. |
The Popular Requests page displays the most popular requests received
by OracleAS 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.

Notice that /localhost:7777/hrapp and /localhost:7777/hrapp/ are not
cached. To learn how to cache these requests, see the OBE titled "Optimizing
OracleAS Web Cache."
|
Back to Topic List
| 1. |
Navigate back to the Web Cache Home page,
and click the Administration tab.

Click the Invalidation link under Operations.

|
| 2. |
Check that the All Objects option is selected, and click Next.

OracleAS Web Cache offers flexible invalidation mechanisms. One method
is to specify the exact object (or objects) for precise invalidation.
Besides Oracle Enterprise Manager interface, OracleAS Web Cache accepts
XML-based invalidation messages at its invalidation port. Telnet or database
triggers can be used to generate the invalidation messages.
|
| 3. |
Check that the Remove objects immediately option is selected,
and click Next. If you select the second option, OracleAS Web Cache
gets a grace period to serve the stale content after invalidation. This
minimizes overloading the origin servers, which results from content refresh
on a big scale. This function is useful for the content that is less critical.
|
| 4. |
Click Finish.

You see Invalidation Result. Click OK.

|
| 5. |
Check the Popular Requests page again. Click the Performance
tab, and then click Popular Requests. All
the cached entries are removed from the Popular Requests table.

|
Back to Topic List
In this lesson, you have learned how
to:
 |
To ask a question about this OBE tutorial, post a query on the OBE
Discussion Forum. |
 |
To learn more about OracleAS Web Cache, click here. |
Place the cursor over this icon to hide all screenshots.
Copyright © 2004 Oracle Corporation. All Rights Reserved.
|