Professional Documents
Culture Documents
8 Simple Caching Rules
8 Simple Caching Rules
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 2
8 Simple Caching Rules
EXECUTIVE SUMMARY
With the arrival of Web caching technology, enterprises no longer have to
compromise the sophisticated look-and-feel of a page in exchange for fast page
delivery. In fact, caching has become a basic element in any Web application design
and deployment. Therefore, an understanding of the application structure and
network systems is important to apply caching effectively. As part of Oracle
Application Server, OracleAS Web Cache enables system administrators and
application developers to optimize performance based upon application uniqueness
and system network parameters. In this paper, the eight simple caching rules are the
key principles to achieve the shortest response time at peak traffic load.
INTRODUCTION
Web caching is essential to speeding up any Web applications. By reducing the
frequency of repeatedly generating content, caching operates according to a caching
policy, based upon the application and the parameters of the system networks.
OracleAS Web Cache 10g is the software industry's leading application acceleration
solution that is designed to accommodate any Web applications and system
environments. OracleAS Web Cache leverages state-of-the-art caching and
compression technologies to optimize application performance and more efficiently
utilize low-cost, existing hardware resources. OracleAS Web Cache is application-
aware; it understands the content of HTTP headers. This level of awareness enables
OracleAS Web Cache to cache any applications without major code rewrite.
Furthermore, OracleAS Web Cache offers built-in workload management to ensure
application reliability and to help maintain quality of service under heavy loads.
Expressed in eight simple caching rules, this paper presents the essential ideas on
Web caching.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 3
an illegitimate request, OracleAS Web Cache serves a pre-set response (typically, an
OracleAS Web Cache can cache non-200
apology page) so that the request never reaches the origin server.
HTTP responses, including those resulting
from denia-of-Service attacks and OracleAS Web Cache supplies a set of default cacheability rules to cache the basic
redirects. static content. Users may also customize and turn on or off cacheability rules using
Oracle Enterprise Manager Application Server Control Console or OracleAS Web
Cache Manager.
A cacheability rule of a particular URL expression may be applied on objects
ending with a file extension, matching a path prefix, or matching regular expression
syntax. Multi-version URL caching uses session cookies or URL parameter to
enable OracleAS Web Cache to distinguish pages with the same URL. Because
OracleAS Web Cache understands the content of HTTP headers, it can cache and
serve different content to different categories of end user, handling personalized
pages.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 4
• Compression: verify that the most popular objects are being served
compressed
• Cacheability rule ordering: cacheability rules which match more popular
objects should be listed before less frequently used rules
From the time the users enter the Web site until they exit, End User Performance
Monitoring identifies the URLs the users have visited and reports the response
times measured from the end users’ perspectives.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 5
RULE 3: DOCUMENT SIZE MATTERS
As explained in Rule 1 and Rule 2, always cache objects that are popular, rarely
change or are resource-intensive to generate. How do large objects fit into this
case?
While large objects may be expensive to generate, the key criteria for whether or
not to cache them is the objects’ popularity. OracleAS Web Cache automatically
“ages out” objects that are rarely requested and those have been in the cache for a
long period of time1. By the same token, when the cache approaches its maximum
cache size, garbage collection removes less popular or old objects. Storing large
objects demands more memory and thus increases the probability of garbage
collection during which OracleAS Web Cache cannot put any objects into the
cache. As a result, frequent garbage collection can seriously hamper the efficiency
of OracleAS Web Cache.
Unless a large object is very popular (relative to other objects that are potentially
cacheable), the expense of consuming extra memory in OracleAS Web Cache may
outweigh the benefit of caching it. Should you need to cache large objects, make
sure that the computer on which OracleAS Web Cache is running has sufficient
memory. To limit the size of objects that can be cached, set a maximum object size.
1 Age, popularity and size are all relative concepts in Web caching. An object that is
“old’ may mean that it has been in the cache for 10 minutes compared to another
object that has been in the cache for 1 minute.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 6
• Expiration Rule: an expiration policy is explicitly embedded a given
cacheability rule
• Standard HTTP headers: OracleAS Web Cache uses the Expires or Cache-
Control header information provided in the response from the origin
server
• Surrogate-Control header: an OracleAS Web Cache specific directive, the
surrogate-control header generated by the origin server specifies the
expiration policy for the given object
Used jointly with expiration or by itself, invalidation provides a higher level of
OracleAS Web Cache supplies some
control and is useful for infrequent changes or for objects that must be up-to-date
sample scripts and APIs for Java, Perl, C,
and PL/SQL for programmatic invalidation. at all times. Invalidation is performed by sending an XML message to OracleAS
Web Cache. The invalidation message may be generated programmatically by an
application or manually through the administrative console. The message contains
a list of expressions for matching objects in the cache. It can also contain “keys”
for marking a group of objects unusable. These keys are part of the origin server’s
response.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 7
• The Inline approach defines the template and the page fragments logically.
The Inline approach is intended for existing applications that are generated
as one whole page. Because the page fragments may not be independently
fetchable, OracleAS Web Cache requests the entire page should the cache
need any of these fragments or templates. The ESI inline tag is inserted
into the page with the fragment name to demarcate the fragment.
OracleAS Web Cache recognizes ESI inline tags and stores the enclosed
portions as separate fragments and the original page as a page template
without the enclosed fragments. Fragments are shared if their names are
identical.
The difference between <esi:include> and <esi:inline> is that the
Inline approach expects the whole page to be loaded the first time. If the
fragments are defined to be fetcheable, then only the fragments are refreshed
subsequently. The big advantage of using <esi:inline> is that the application
will still run even without an ESI processor.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 8
• Keep-Alive: HTTP Keep-Alive allows TCP connections to be re-used for
multiple requests. Keep-Alive should be enabled for both HTTP client to
OracleAS Web Cache and for OracleAS Web Cache to origin server
communication. OracleAS Web Cache uses connection pooling to its
origin server and re-uses the origin server connections whenever possible.
To enhance availability, cache capacity and performance, you can cluster OracleAS
Keeping the system and architecture setup
Web Cache instances into a single logical cache for improved scalability, availability
in mind is important in effective use of
Web caching. and capacity of the cache tier. Clustering has automatic content provisioning,
partitioning the content space for increased cache capacity and replicating popular
content for performance and high availability. No specialized hardware is required,
although a fast network for intra-cache communication is desirable. Clustering
OracleAS Web Caches running on different operating systems is supported. For
example, a Web Cache running on Microsoft Windows can be clustered with one
running on GNU/Linux.
There are also management benefits to clustering OracleAS Web Cache. All caches
in the cluster can be managed, controlled and monitored from any node in the
cluster. Invalidation messages may also be sent to any node in the cluster. The
cluster automatically propagates the invalidation message to all members of the
cluster, keeping the entire cluster consistent.
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 9
CONCLUSION
OracleAS Web Cache offers the industry’s most versatile and robust application
acceleration solution. Not only is it application aware, it also cooperates with
network systems to deliver any Web site in the shortest amount of time possible
with minimum downtime. From caching, partial-page caching to content
consistency, and from compression, SSL acceleration to system tuning, all of these
areas affect the overall effectiveness of OracleAS Web Cache. In eight simple rules,
this paper has outlined how to help Web caching your application for fast response
time!
8 Simple Caching Rules – Web Caching Your Application for Fast Response Time Page 10
8 Simple Caching Rules
December 2004
Author: Christine Chan, Patrick Fry
Contributing Authors:
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.
Worldwide Inquiries:
Phone: +1.650.506.7000
Fax: +1.650.506.7200
www.oracle.com