280 likes | 495 Views
Ric Goell Ming Lei Web Cache Oracle Corporation. Web Caching for Database Centric Applications. Outline. Part I - Introduction to Web Caching Part II - Designing with Caching in Mind A process for analyzing the potential for caching benefits Part III – Partial Page Caching with ESI
E N D
Ric GoellMing Lei Web Cache Oracle Corporation
Web Caching for Database Centric Applications
Outline • Part I - Introduction to Web Caching • Part II - Designing with Caching in Mind • A process for analyzing the potential for caching benefits • Part III – Partial Page Caching with ESI • Edge Side Includes (ESI) – a standards based technology for page and fragment caching • JESI – A set of JSP tags that support ESI
Part I Why Web Caching? • Content is becoming more dynamic for a richer and more personal Web experience. • The number of people using web based applications is growing beyond the limits of traditional infrastructures. • User expectations are growing – they expect more relevant content and fast response times • Large “Farms” are costly to purchase and manage
Internet/Intranet Caching on the Web $ $ $ $ $ $ $ $ CDN/eCDN Central Data Center Browser Cache Forward Proxy Edge Servers Reverse Proxy Application Server Database
Cache Hit Rate • Cache hits are practically free when compared to generating dynamic pages. • Focus is on improving cache hit rates.
Why don’t more apps provide caching • “But my pages have too much customization to be cacheable.” • A lame excuse – new tools allow customized and dynamic content to be cached • Page fragments can be assembled • Request and Response Variables can be included • Cache Consistency tools to help with invalidation
Part II: Designing with Caching in Mind • A 3 Step Process • Page Analysis – Determining what to cache • Disambiguation – Key Generation • Cache Consistency – Removing items from cache
Page Analysis When designing a page layout, define fragments with similar cache policies – early in design process • When evaluating the benefit of caching pages or fragments, each of the following should be considered: • Share-ability – How many users share this content? • Generation Cost – How computationally intensive is the generation of this content? • Frequency – How many times will this content be viewed (even within one user’s session) before it changes? • Note that even user specific content may be desirable to cache if it accessed frequently
Disambiguation – Cache Key Definition Differentiating documents based on specific requests. • URLs • Post Body • HTTP Headers • Cookies • MVC Apps tend to have less information in the request. Heavy use of backend state can reduce Web Cache benefits.
Consistency Management • Expiration – Time Based • Invalidation based – explicit message to cache servers to remove content from cache • Validation Based • ETAG and GIMS (similar capabilities for fragments) • Don’t be unnecessarily restrictive
Session State Management • Web Sites often use session keys to track user state and identify data on the server side. • Web Cache was designed to work with sessions by transparently allowing session establishment and updates. • Additionally it was designed to allow for caching of documents that include sessions.
Session Encoded URLs Session Bhttp://store.oracle.com/cec/cstage?session_ID=33437 Session Ahttp://store.oracle.com/cec/cstage?session_ID=33436
Part III PartialPage Caching & Content Assembly • Edge Side Includes (ESI) • an XML-like markup language used to define cacheable and non-cacheable content fragments • a content invalidation protocol for cache consistency • Edge Side Includes for Java (JESI) • a custom tag library to facilitate the use of ESI with JSP applications
Industry Support for ESI An open specification.ESI published as a W3C Note. JESI submitted to JCP as JSR 128.See www.esi.org for more info.
Tag Purpose Used in a “template” page to indicate to the ESI processor how to assembe the fragments (the tag generates the <esi:include> tag. <jesi:include> <jesi:control> Assign an attribute (e.g., expiration) to templates and fragments. Used to contain the entire content of a JSP container page within its body. <jesi:template> <jesi:fragment> Encapsulate individual content fragments within a JSP page. Specify that a particular piece of code needs to be executed before any other fragment is executed. <jesi:codeblock> Explicitly remove and/or expire selected objects cached in an ESI processor. <jesi:invalidate> Insert personalized content into a page where the content is placed in cookies and inserted into the page by the ESI processor. <jesi:personalize> Summary of JESI Tags
JESI Personalization <HTML>Welcome to the Oracle Store <jes:personalize name=”user_name”> ...</HTML> The URL query string has the Personal Valuehttp://Machine:port/zyz?user_name=Jane
Why ESI? • ESI is in production • Co-developed with Akamai and Oracle • IBM is also implementing ESI • ESI is an open language • Maturing through real usage • W3c note
ESI at a glance • Templates and Fragments • include & inline • Variables • Query String Variables • Cookie Variables • Environment Variables • A good sample App: • http://otn.oracle.com/sample_code/products/ias/web_cache/htdocs/jesi/Readme.html
ESI Personalization <HTML>Welcome to the Oracle Store<esi:vars> $(QUERY_STRING{'user_name'})! </esi:vars> ...</HTML> The URL query string has the Personal Valuehttp://Machine:port/zyz?user_name=Jane
/news101 Template Cache Storage Page Assembly Cache Response /sample.html <esi:include> Model /sample.html (template) <html> ... <esi:include src=”/news101”> ... </html> /news101 <table> ... </table>
/stocks.xml Template Cache Storage Page Assembly Cache Response /sample.html <esi:environment> /sample.html ... <esi:environment src=/stocks.xml name=stock/> ... <esi:vars> ORCL $(stock{orcl_p}) $(stock{orcl_c}) YHOO $(stock{yhoo_p}) $(stock{yhoo_c}) </esi:vars> ... /stocks.xml <orcl_p>8.94</orcl_p> <orcl_c>+0.09</orcl_c> <yhoo_p>16.55</yhoo_p> <yhoo_c>-0.46</yhoo_c>
Template 1 Fragment 1 Fragment 2 Fragment 3 ESI - Storage & Assembly • Parsing is only done the first time a page is fetched. • A buffer array is generated for a scatter/gather network write • This buffer is maintained in the cache for fast cache hits without page assembly processing Buffer Array
ESI Performance • This test measured a real portal application without Web Cache and ESI. • Either the Portal App or Web Cache did the page assembly • 10 portlets
Other Interesting Web Cache Features / Topics • Invalidation / Consistency Management • Expiration based • Invalidation based • Clustering • Cache Hierarchies