Oracle® Fusion Middleware Administrator's Guide for Oracle Web Cache 11g Release 1 (11.1.1) E10143-03 |
|
![]() Previous |
![]() Next |
This chapter discusses how to configure Oracle Web Cache with third-party application Web servers.
This chapter includes the following topics:
Notes:
|
Because Oracle Web Cache is transparent to the application Web server, the application Web server treats HTTP requests from Oracle Web Cache as any other HTTP request coming directly from the browser. In turn, the application Web server generates the response and sends it back to Oracle Web Cache as an HTTP message.
Because Oracle Web Cache fully supports HTTP, it can work with any HTTP-compliant application Web server. How the application Web servers choose to generate HTTP responses is irrelevant to Oracle Web Cache.
The type of application Web server that a site uses depends mainly on the types of applications that site is running. For example, if customers want to run Active Server Pages (ASP), then they may prefer to use Microsoft Internet Information Server (IIS) as the application Web server.
You configure Oracle Web Cache to communicate with a third-party application Web server the same way you do with Oracle HTTP Server, by providing the host name and the listening port number. Table 12-1 shows the default values for the listening ports for the products discussed in this appendix.
Table 12-1 Third-Party Application Web Server Default Listening Ports
Application Web Server | Port |
---|---|
IBM WebSphere Application Server, Version 6.0 |
|
Apache Tomcat, Version 4.1 |
|
Microsoft IIS 6.0 |
80 |
To configure Oracle Web Cache to communicate with a third-party application Web server, perform the following tasks:
See Section 2.11.1 to change Oracle Web Cache port settings
See Section 2.11.2 configure application Web server settings
See Section 2.11.3 and Section 2.11.4 configure Web site settings
You assign caching rules and expiration rules when using third-party application Web servers in the same way as when using Oracle HTTP Server. You can choose to cache or not to cache content for the following:
Static objects
Multiple-version objects for the same URL
Pages supporting a session cookie or embedded URL parameter
Pages containing simple personalization
Dynamic assembly of Edge Side Includes (ESI) fragments
You can also assign an expiration time limit to objects or invalidate objects at any time. See Chapter 6, "Caching and Compressing Content," and Chapter 7, "Invalidating Content."
When Oracle Web Cache fetches static content from IBM Websphere Application server, the IBM Websphere Application Server sends a content="ESI/1.0+"
directive in the Surrogate-Control
response header in the response to the Oracle Web Cache Surrogate-Capability: orcl="ESI/1.0"
request. Oracle Web Cache ignores the ESI/1.0+ features to get rid of page rendering issues and errors. If Oracle Web Cache is deployed as a caching solution, this difference in the control directive value may result in undefined Web application behavior.
Follow these steps to force IBM Websphere Application Server to send ESI/1.0 instead of ESI/1.0 or later:
In the WebSphere Application Server administrative console, navigate to Servers > Application servers.
The Application servers page appears.
In the Application servers page appears, select the server1
application server.
server1
is the server name when IBM Websphere Application Server is installed with default options. If you specified a different name, select that name instead.
In the Server Infrastructure section of the Configuration tab, select Java and Process Management, and then Process Definition.
In the Additional Properties section, select Java Virtual Machine, and then Custom Properties.
Click New to create an entry.
In the Name field, enter com.ibm.servlet.file.esi.control
.
In the Value field, enter max-age=300, cacheid="URL", content="ESI/1.0"
.
Click Apply, then save and restart WebSphere Application Server.
The WebSphere Application Server installation includes several JSP, Java servlets, and EJB examples. This section explains how to configure Oracle Web Cache to cache the following content:
The snoop
servlet shows getting and using request information, headers, and parameters sent by the browser. Use it to demonstrate how Oracle Web Cache caches full-page dynamic content.
To cache the snoop
servlet:
Ensure that Oracle Web Cache has been configured to communicate with the WebSphere Application Server, as described in Section 12.1.1.
Start the WebSphere Application Server, and then access the following URL:
http://hostname/snoop
Notice that request information, headers, and parameters sent by your browser display.
Create a caching rule for the snoop
output, as described in Section 6.8.
When creating the caching rule for the snoop
output, ensure you configure the following in the Create Caching Rule page:
Click the Cache check box.
In the Match URL By section, select Path Prefix and enter /snoop
.
In the HTTP Methods section, click GET.
Point the browser to Oracle Web Cache with following URL:
http://web_cache_hostname:admin_port/snoop
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed snoop
directly from the WebSphere Application Server. This time, Oracle Web Cache caches the snoop
output and serves the response to the browser.
View the contents of the cache, as described in Section 8.6, to ensure that snoop
is cached.
When you reload the page, you should notice that the cached response appears faster than when you access the WebSphere Application Server directly.
The Calendar
JSP generates a calendar based on user input. The example is not a pre-deployed WebSphere example like the snoop
servlet. To find this example, install Technology Samples, as mentioned in the documentation under IBM WebSphere Application Server samples gallery. Use this JSP to demonstrate how Oracle Web Cache caches pages with session cookies.
To cache SimpleTag.jsp
for session-encoded URLs:
Start the WebSphere Application Server, set the browser to accept cookies, and then access the following URL:
http://hostname/TechnologySamples/Calendar
Notice that the page displays a form asking for inputs on month, year, and other preferences to create a calendar. To use the application:
Enter some values, and then click Continue.
Enter some values in the Day and Memo fields, and then click Add Memo.
Click Generate Calendar.
Create an expiration rule, as described in Section 6.7.
In the Create Expiration Policy dialog box, perform the following steps:
In the Objects Expire section, select After Cache Entry and enter 60
seconds in the Time Limit field.
In the Action On Expired Objects section, select Remove Immediately.
Create a session caching rule, as described in Section 6.8.6.
When configuring a session caching rule, perform the following steps:
When creating a session definition in the Session Definitions section of the Session Configuration page:
In the Session Name field, enter IBMSession
.
In the Cookie Name field, enter JSESSIONID
.
In the URL Post Body Parameters field, enter jsessionid
.
In the Session Policy Configuration section of the Session Configuration page, create two policies named IBMSession
:
In the Cache column for the first IBMSession policy, select the With Session option.
In the Cache column for the second IBMSession policy, select the Without Session option.
Do not select the Substitute Default Value check box.
Create a new caching rule for Calendar
.
When creating the caching rule for the Calendar
output, configure the following in the General tab of the Create Caching Rule page:
Click the Cache check box.
From the Expiration list, select Expire 60 seconds after cache entry and remove immediately.
In the Match URL By section, select Path Prefix and enter /TechnologySamples/Calendar
.
In the HTTP Methods section, click GET.
In the Sessions tab of Create Caching Rule page, select both the IBMSession sessions, one using setting Without Session and the other using setting With Session.
Point the browser to Oracle Web Cache with the following URL:
http://web_cache_hostname:WebCache-admin_port/TechnologySamples/Calendar
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed Calendar
directly from WebSphere Application Server. This time, Oracle Web Cache caches the Calendar
output.
View the contents of the cache, as described in Section 8.6, to ensure that Calendar
is cached.
When you reload the page, notice that the cached response appears faster than when you access the WebSphere server directly.
Because the expiration rule for this URL is set to 60 seconds, Oracle Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
After deploying Oracle Web Cache, if the browser displays a HTTP 404 Page not found error
, perform the following steps:
In the WebSphere Server WAS_home
/config/cells/plugin-cfg.xml
file, add <VirtualHost Name="*:WebCache-admin_port"/>
.
In the WebSphere Application Server administrative console, navigate to Environment > Virtual Hosts.
Follow the prompts to add a new virtual host.
Apache Tomcat, Version 4.1 is a servlet container. It is included with the Apache Jakarta Project. The Apache Tomcat installation includes several JSP and Java servlet examples. This section explains how to configure Oracle Web Cache to cache the following content:
Follow the instructions enclosed within the Apache Tomcat binary for installation. Apache Tomcat requires the Java Development Kit (JDK).
For more information, see:
http://jakarta.apache.org/tomcat/
for further information about Apache Tomcat
http://java.sun.com
for further information about downloading and installing JDK
snoop.jsp
shows getting and using request information, headers, and parameters sent by the browser. Use it to demonstrate how Oracle Web Cache caches full-page dynamic content.
To start, perform the following steps:
Ensure that Oracle Web Cache has been configured to communicate with the Apache Tomcat server, as described in Section 12.1.1.
Start the Apache Tomcat server, and then access the following URL:
http://web_cache_hostname:WebCache-admin_port/examples/jsp/snp/snoop.jsp
Notice that request information, headers, and parameters sent by your browser display.
To cache this content:
Create a caching rule for the snoop
output, as described in Section 6.8.
When creating the caching rule for the snoop
output, ensure you configure the following in the Create Caching Rule page:
Click the Cache check box.
In the Match URL By section, select Path Prefix and enter /examples/jsp/snp/snoop.jsp
.
In the HTTP Methods section, click GET.
Point the browser to the Oracle Web Cache with following URL:
http://web_cache_hostname:admin_port/eexamples/jsp/snp/snoop.jsp
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed snoop
directly from Apache Tomcat. This time, Oracle Web Cache caches the snoop
output and serves the response to the browser.
View the contents of the cache, as described in Section 8.6, to ensure that snoop
is cached.
When you reload the page, you should notice that the cached response appears faster than when you access Apache Tomcat directly.
The SessionServlet
provides a simple example of an HTTP servlet that uses the HttpSession
class to track the number of times that a browser has visited the servlet. Use it to demonstrate how Oracle Web Cache caches pages with session-encoded URLs.
This servlet may not be included in the Apache Tomcat binary. You can find this example on the Web, or you can use code for the servlet from Example 12-1.
Example 12-1 Apache Tomcat Binary
/* * @(#)SessionServlet.java 1.5 1.5 * * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. * * CopyrightVersion 1.0 */ package sunexamples; import java.io.*; import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; /** * This is a simple example of an HTTP Servlet that uses the HttpSession * class * * Note that in order to guarantee that session response headers are * set correctly, the session must be retrieved before any output is * sent to the client. */ public class SessionServlet extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //Get the session object HttpSession session = req.getSession(true); //Get the output stream ServletOutputStream out = res.getOutputStream(); res.setContentType("text/html"); out.println("<HEAD><TITLE> SessionServlet Output " + "</TITLE></HEAD><BODY>"); out.println("<h1> SessionServlet Output </h1>"); //Here's the meat Integer ival = (Integer) session.getValue("sessiontest.counter"); if (ival==null) ival = new Integer(1); else ival = new Integer(ival.intValue() + 1); session.putValue("sessiontest.counter", ival); out.println("You have hit this page <b>" + ival + "</b> times.<p>"); // encodeURL Encodes the specified URL by including the session ID in it // if cookies are not turned on or not supported by the browser out.println("Click <a href=" + res.encodeURL("/session.html") + ">here</a>"); out.println(" to ensure that session tracking is working even if" + " cookies aren't supported.<br>"); out.println(" Note that by default URL rewriting is not enabled due" + " to it's expensive overhead."); out.println("<p>"); out.println("<h3>Request and Session Data:</h3>"); out.println("Session ID in Request: " + req.getRequestedSessionId()); out.println("<br>Session ID in Request from Cookie: " + req.isRequestedSessionIdFromCookie()); out.println("<br>Session ID in Request from URL: " + req.isRequestedSessionIdFromURL()); out.println("<br>Valid Session ID: " + req.isRequestedSessionIdValid()); out.println("<h3>Session Data:</h3>"); out.println("New Session: " + session.isNew()); out.println("<br>Session ID: " + session.getId()); out.println("<br>Creation Time: " + session.getCreationTime()); out.println("<br>Last Accessed Time: " + session.getLastAccessedTime()); out.println("<br><a href=\"/examples/simple_servlets\">Up</a>"); out.println("</BODY>"); out.close(); } public String getServletInfo() { return "A simple session servlet"; } }
To start, perform the following steps:
Compile the SessionServlet.java
file in the Apache Tomcat environment.
Copy the SessionServlet.class
to the /examples/servlets/
directory where other servlet examples may reside.
Ensure that Oracle Web Cache has been configured to communicate with the Apache Tomcat, as described in Section 12.1.1.
Configure the browser not to accept cookies.
This is required to use session-encoded URLs in this example.
Start Apache Tomcat and access the following URL:
http://hostname/examples/servlets/SessionServlet
Notice that the page displays how many times a browser has visited it. When you click the link labeled here, notice that the session ID is encoded in the URL. Every time you refresh or reload the page, the counter increases by one.
To cache the content:
Create an expiration rule, as described in Section 6.7.
In the Create Expiration Policy dialog, perform the following steps:
In the Objects Expire section, select After Cache Entry and enter 60
in the Time Limit field.
In the Action on Expired Objects section, select Remove Immediately.
Create a session caching rule, as described in Section 6.8.6.
When configuring a session caching rule, perform the following steps:
When creating a session definition in the Session Definitions section of the Session Configuration page:
In the Session Name field, enter ApacheSession
.
In the Cookie Name field, enter JSESSION
.
In the URL Post Body Parameters field, enter jsessionid
.
In the Session Policy Configuration section of the Session Configuration page, create two policies named ApacheSession
:
In the Cache column for the first ApacheSession policy, select the With Session option.
In the Cache column for the second ApacheSession policy, select the Without Session option.
Do not select the Substitute Default Value check box.
Create a new caching rule for Session
.
When creating the caching rule for the SessionServlet
servlet output, configure the following in the General tab of the Create Caching Rule page:
Click the Cache check box.
From the Expiration list, select Expire 60 seconds after cache entry and remove immediately.
In the Match URL By section, select Path Prefix and enter /examples/servlets/SessionServlet
.
In the HTTP Methods section, click GET.
In the Sessions tab of Create Caching Rule page, select both the ApacheSession sessions, one using setting Without Session and the other using setting With Session.
Create a session caching rule as described in Section 6.8.6.
Point the browser to Oracle Web Cache with the following URL:
http://web_cache_hostname:WebCache-admin/examples/servlets/SessionServlet
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed Session
servlet directly from Apache Tomcat. This time Oracle Web Cache caches the Session
servlet output. When the page is refreshed or reloaded, notice that the counter does not increment by one. This is because Oracle Web Cache serves the content, and the request never goes to the Apache Tomcat.
View the contents of the cache, as described in Section 8.6, to ensure that Session
servlet is cached.
When you reload the page, notice that the cached response appears faster than when you access the Apache Tomcat server directly.
Because the expiration rule for this URL is set to 60 seconds, Oracle Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
The Microsoft IIS installation includes several ASP examples. This section explains how to configure Oracle Web Cache to cache the following content:
ServerVariables_JScript.asp
demonstrates techniques you can use to access server variable information from an ASP script. Use it to demonstrate how Oracle Web Cache caches full-page dynamic content.
To start, perform the following steps:
Ensure that Oracle Web Cache has been configured to communicate with IIS, as described Section 12.1.1.
Start IIS, and then access the following URL:
http://hostname/IISSamples/sdk/asp/interaction/ServerVariables_JScript.asp
Notice that request information, headers, and parameters sent by the browser display.
To cache this content:
Create a caching rule for the ServerVariables_JScript.asp
, as described in Section 6.8, using the following information:, configure the following in the Create Caching Rule page:
When creating the caching rule for the ServerVariables_JScript.asp output, configure the following in the Create Caching Rule page:
In the Match URL By section, enter:
/IISSamples/sdk/asp/interaction/ServerVariables_JScript.asp
In the HTTP Methods section, click GET.
In the Caching Response section, click Cache.
Point the browser to Oracle Web Cache with following URL:
http://web_cache_hostname:WebCache-admin_port/eIISSamples/sdk/asp/interaction/ServerVariables_JScript.asp
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed ServerVariables_JScript.asp
directly from IIS. This time, Oracle Web Cache caches the ServerVariables_JScript.asp
output and serves the request to the browser.
View the contents of the cache, as described in Section 8.6, to ensure that ServerVariables_JScript.asp
is cached.
When you reload the page, you should notice that the cached response appears faster than when you access IIS directly.
Cookie_JScript.asp
illustrates how your script can set and read cookies by using the Response.Cookies
collection. Use it to demonstrate how Oracle Web Cache caches pages with session cookies.
To start, perform the following steps:
Ensure that Oracle Web Cache has been configured to communicate with IIS, as described in Section 12.1.1.
Start IIS, verify that your browser is set to accept cookies, and then access the following URL:
http://hostname/IISSamples/sdk/asp/interaction/Cookie_JScript.asp
When you access the URL, notice that the page displays the date and time you last visited this page. When you click "Revisit this page," the date and time is updated.
To cache this content:
Create an expiration rule, as described in Section 6.7.
In the Create Expiration Policy dialog, perform the following steps:
In the Objects Expire section, select After Cache Entry and enter 60
in the Time Limit field.
In the Action on Expired Objects section, select Remove Immediately.
Create a session caching rule, as described in Section 6.8.6.
When configuring a session caching rule, perform the following steps:
When creating a session definition in the Session Definitions section of the Session Configuration page:
In the Session Name field, enter MSSession
.
In the Cookie Name field, enter CookieJSCript
.
In the URL Post Body Parameters field, enter jsessionid
.
In the Session Policy Configuration section of the Session Configuration page, create two policies named MSSession
:
In the Cache column for the first MSSession policy, select the With Session option.
In the Cache column for the second MSSession policy, select the Without Session option.
Do not select the Substitute Default Value check box.
Create a new caching rule for Cookie_JScript.asp
.
When creating the caching rule for the Cookie_JScript.asp
output, configure the following in the General tab of the Create Caching Rule page:
Click the Cache check box.
From the Expiration list, select Expire 60 seconds after cache entry and remove immediately.
In the Match URL By section, enter /IISSamples/sdk/asp/interaction/Cookie_JScript.asp
.
In the HTTP Methods section, click GET.
In the Sessions tab of Create Caching Rule page, select both the MSSSession sessions, one using setting Without Session and the other using setting With Session.
Point the browser to Oracle Web Cache with the following URL:
http://web_cache_hostname:WebCache-admin_port/eIISSamples/sdk/asp/interaction/Cookie_JScript.asp
See Section 2.11.1.1 to determine the port.
The output is the same when you accessed Cookie_JScript.asp
directly from IIS. This time, Oracle Web Cache caches the Cookie_JScript.asp
output. To verify that the cache serves the content, click "Revisit this page." Notice that the date and time are not updated. This is because Oracle Web Cache serves the cached content, and the request never goes to IIS.
View the contents of the cache, as described in Section 8.6, to ensure that Cookie_JScript.asp
is cached.
When you reload the page, notice that the cached response appears faster than when you access IIS server directly.
Because the expiration rule for this URL is set to 60 seconds, Oracle Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.