Oracle Application Server Web Cache Administrator's Guide 10g (9.0.4) Part Number B10401-01 |
|
This chapter discusses how to configure OracleAS Web Cache with third-party application Web servers.
This chapter contains these topics:
Because OracleAS Web Cache is transparent to the application Web server, the application Web server treats HTTP requests from OracleAS 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 OracleAS Web Cache as an HTTP message.
Because OracleAS 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 OracleAS 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.
This section contains these topics:
You configure OracleAS Web Cache to communicate with a third-party application Web servers the same way you do with Oracle HTTP Server, by providing the host name and the listening port number. The default values for the listening ports for the products discussed in this chapter are given in Table D-1.
Application Web Server | Port |
---|---|
BEA WebLogic Server 6.0 |
7001 |
IBM WebSphere Application Server, Version 4.0 |
80 |
Apache Tomcat, Version 4.1 |
8080 |
Microsoft IIS 5.0 |
80 |
To configure OracleAS Web Cache to communicate with a third-party application Web server, perform the following tasks:
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:
You can also assign an expiration time limit to documents or invalidate documents at any time.
The WebLogic Server 6.0 installation includes a number of Java Server Pages (JSP), Java servlets, and Enterprise JavaBeans (EJB) examples. For the purposes of this section, the following examples are used:
The SnoopServlet
servlet obtains and uses request information, headers, and parameters sent by the browser. Use it to demonstrate how OracleAS Web Cache caches full-page dynamic content with SnoopServlet
.
To start, perform the following steps:
http://hostname:7001/examplesWebApp/SnoopServlet
When you access the URL, notice that your browser displays request information, headers, parameters, and the GIF image "Build On bea."
To cache the content:
SnoopServlet
output, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the SnoopServlet
output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
http://web_cache_hostname
:7777/examplesWebApp/SnoopServlet
The output is the same as it was when you accessed SnoopServlet
directly from the WebLogic Server. This time, OracleAS Web Cache caches the SnoopServlet
output and serves the request to the browser.
SnoopServlet
is cached.
From this point on, anytime a browser accesses SnoopServlet
, the response will be served from OracleAS Web Cache.
The SessionServlet
servlet 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 OracleAS Web Cache caches pages with session-encoded URLs.
To start, perform the following steps:
This is required in order to use session-encoded URLs in this example. Finally, start the WebLogic Server and access the following URL:
http://hostname
:7001/examplesWebApp/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:
In the Create Expiration Policy dialog box, perform the following steps:
When configuring a session-caching policy for SessionServlet
, perform the following steps:
SessionServlet
, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the SessionServlet
output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
/examplesWebApp/SessionServlet
.
http://web_cache_hostname
:7777/examplesWebApp/SessionServlet
The output is the same as it was when you accessed SessionServlet
directly from the WebLogic Server. This time OracleAS Web Cache caches the SessionServlet
output. When the page is refreshed or reloaded, notice that the counter does not increment by one. This is because OracleAS Web Cache serves the content, and the request never goes to the WebLogic Server.
SessionServlet
is cached.
When you reload the page, notice that the cached response appears faster than when you access the WebLogic server directly.
Because the expiration rule for this URL is set to 60 seconds, OracleAS Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
The WebSphere Application Server, Version 4.0 installation includes a number of JSP, Java servlets, and EJB examples. For the purposes of this section, the following examples are used:
The snoop
servlet shows getting and using request information, headers, and parameters sent by the browser. Use it to demonstrate how OracleAS Web Cache caches full-page dynamic content.
To start, perform the following steps:
http://hostname
/servlet/snoop
Notice that request information, headers, and parameters sent by your browser are displayed.
To cache this content:
snoop
output, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the snoop
output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
http://web_cache_hostname
:7777/servlet/snoop
The output is the same as it was when you accessed snoop
directly from the WebSphere Application Server. This time, OracleAS Web Cache caches the snoop
output and serves the response to the browser.
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 SessionSample
servlet is a simple example of an HTTP servlet that tracks the number of times that a browser has visited the servlet using a cookie. Use it to demonstrate how OracleAS Web Cache caches pages with session cookies.
This example is not a pre-deployed WebSphere example like the snoop
servlet. You can find this example in Section 4.4.1.1: Session programming model and environment in the WebSphere Application Server online documentation, when you click the SessionSample.java
link on that page.
To start, perform the following steps:
SessionSample.java
file in the WebSphere environment.
SessionSample.class
file to the location where the snoop.class
file resides.
The default location for the snoop.class
file is WebSphere's install directory:
\WebSphere\AppServer\hosts\default_host\default_app\servlets\
http://hostname
/servlet/SessionSample
Notice that the page displays the number of times a browser has visited this page. When you reload this page, the counter increments by one.
To cache this content:
In the Create Expiration Policy dialog box, perform the following steps:
When configuring a session-caching policy, perform the following steps:
SessionSample
, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the SessionSample
output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
/servlet/SessionSample
.
http://web_cache_hostname
:7777/servlet/SessionSample
The output is the same as when you access SessionSample
directly from WebSphere Application Server. This time, OracleAS Web Cache caches the SessionSample
output. To verify that the content is served by the cache, refresh or reload the page. Notice that the counter remains the same. This is because OracleAS Web Cache serves the content, and the request never goes to WebSphere Application Server.
SessionSample
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, OracleAS Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
Apache Tomcat, Version 4.1 is a servlet container. It is included with the Apache Jakarta Project. The Apache Tomcat, Version 4.1 installation includes a number of JSP and Java servlet examples. For the purposes of this section, the following examples are used:
Follow the instructions enclosed within the Apache Tomcat binary for installation. Apache Tomcat requires the Java Development Kit (JDK).
See Also:
|
snoop.jsp
shows getting and using request information, headers, and parameters sent by the browser. Use it to demonstrate how OracleAS Web Cache caches full-page dynamic content.
To start, perform the following steps:
http://hostname
/examples/jsp/snp/snoop.jsp
Notice that request information, headers, and parameters sent by your browser are displayed.
To cache this content:
snoop
output, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the snoop
output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
http://web_cache_hostname
:7777/examples/jsp/snp/snoop.jsp
The output is the same as it was when you accessed snoop
directly from Apache Tomcat. This time, OracleAS Web Cache caches the snoop
output and serves the response to the browser.
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 OracleAS 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 D-1.
/* * @(#)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:
SessionServlet.java
file in the Apache Tomcat environment.
SessionServlet.class
to the /examples/servlets/
directory where other servlet examples may reside.
This is required in order to use session-encoded URLs in this example.
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:
In the Create Expiration Policy dialog box, perform the following steps:
When configuring a session-caching policy for the Session
servlet, perform the following steps:
SessionServlet
, as described in "Configuring Caching Rules and Rule Association".
When creating the caching rule for the Session
servlet output, configure the following in the Edit/Add Caching, Personalization, and Compression Rule dialog box:
/examples/servlets/SessionServlet
.
http://web_cache_hostname
:7777/examples/servlets/SessionServlet
The output is the same as it was when you accessed Session
servlet directly from Apache Tomcat. This time OracleAS 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 OracleAS Web Cache serves the content, and the request never goes to the Apache Tomcat.
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, OracleAS Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
The IIS 5.0 installation includes a number of ASP examples. For the purposes of this section, the following examples are used:
ServerVariables_JScript.asp
demonstrates techniques you can use to access server variable information from an ASP script. Use it to demonstrate how OracleAS Web Cache caches full-page dynamic content.
To start, perform the following steps:
http://hostname
/IISSamples/sdk/asp/interaction/ServerVariables_JScript.asp
Notice that request information, headers, and parameters sent by the browser are displayed.
To cache this content:
ServerVariables_JScript.asp
, as described in "Configuring Caching Rules and Rule Association", using the following information:
/IISSamples/sdk/asp/interaction/ServerVariables_JScript.asp.
http://web_cache_
hostname
:7777/IISSamples/sdk/asp/interaction/ServerVariables_JScript.asp
The output is the same as it was when you accessed ServerVariables_JScript.asp
directly from IIS. This time, OracleAS Web Cache caches the ServerVariables_JScript.asp
output and serves the request to the browser.
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 OracleAS Web Cache caches pages with session cookies.
To start, perform the following steps:
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:
In the Create Expiration Policy dialog box, perform the following steps:
Cookie_Jscript.asp
, as described in "Configuring Session or Personalized Attribute Caching Policies".
When configuring a session caching policy, perform the following steps:
MSSession
.
CookieJSCript
.
Cookie_JScript.asp
, as described in "Configuring Caching Rules and Rule Association".
Cookie_JScript.asp
output, configure the following in the Edit/Add Caching, Personalization, and Compression dialog box:
/IISSamples/sdk/asp/interaction/Cookie_JScript.asp
.
http://web_cache_hostname
:7777/IISSamples/sdk/asp/interaction/Cookie_
JScript.asp
The output is the same as it was when you accessed Cookie_JScript.asp
directly from IIS. This time, OracleAS 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 OracleAS Web Cache serves the cached content, and the request never goes to IIS.
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, OracleAS Web Cache expires the cached content after 60 seconds and reflects the content the next time the user requests the page.
|
![]() Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
|