欢迎光临
我们一直在努力

动态缓冲

建站超值云服务器,限时71元/月

dynamic caching

by wayne berry

introduction

caching happens at all levels, on the hard drive, in ram, and within the operating systems. it is a

performance fundamental of computer science. in 1999, a wave of caching products swept the internet to

serve graphics faster. these products drove the stock of companies like akamai technologies, inc., and

inktomi corp. into the sky. however, they were focused on caching graphics and streaming media.

now a new wave of caching products are emerging that cache dynamic web pages. dynamic web pages are those

that are created between the request for the page and the response back to the browser. usually they are

written in a scripting language like perl, cgi, vbscript, or cold fusion. in the past, these pages were

used to provide personalization and e-commerce transactions. however, as the web evolves, dynamic pages

are being used to generate content-like promotions for the front page, changing indexes and mainstream

content. because these types of pages are being used for web-site maintenance and not user interactivity,

they can be cached for short periods of time.

dynamic cachings time has come, post point software launched a released of xcache in may, microsoft plans

to release asp+ and acceleration server next year, cold fusion released spectre at the end of 1999, and

vignettes story server lists caching as one of their main features. however, if you are writing your web

site in active server pages (asps), it was not until xcache that you could implement partial page caching

(the ability to cache just a portion of the page, leaving the rest dynamic). this ability allows you to

incorporate personalization without losing performance.

this article will cover three ways to cache your dynamic web site written in asps, including microsoft

acceleration server, microsofts asp+, and post point softwares xcache, and offer the pros and cons of

using each product. if you are looking for speed and scalability for the web site, read on.

microsoft security and internet acceleration server (isa)

microsofts security and internet acceleration server, a.k.a. isa (<a

href="http://www.microsoft.com/isaserver/"> http://www.microsoft.com/isaserver</a> ), is the third version

of their reverse proxy server (still in beta). the isa server is typical of reverse proxy servers and is

somewhat advanced in its handling of urls with question marks (dynamic pages). while most reverse proxy

servers dont recognize query strings as unique identifiers to the pages, isa does cache each page with

unique query strings as separate pages.

what is a reverse proxy server?

the proxy server sits between the internet and the web site and handles all traffic before it can reach

the web server. a reverse proxy server intercepts requests to the web server and instead responds to the

request out of a store of cached pages. this method improves the performance by reducing the amount of

pages actually created "fresh" by the web server.

reverse proxy servers cache pages based on http header tags that are returned from the dynamic pages. the

four most important are:

last-modified tells the proxy when to change the page. expires tells the proxy when to drop the

page. cache-control tells the proxy if the page should be cached. pragma. tells the proxy if the

page should be cached.

for example, by default all active server pages return "cache-control: private." which means that none of

your active server pages will be cached with microsofts acceleration server.

advantages

the isa server runs on a separate machine that distributes the load from the web server to the

acceleration server. the isa server also serves everything from ram, making it extremely quick.

disadvantages

with the isa server you need to recode your active server pages in order to cache them — active server

pages default http response headers will tell the isa server not to cache its pages. because the isa

server sits on a separate machine, none of the cached requests make it to the internet information

servers log files. this means that even though those pages are being requested, there is no record of it

on the web server, so your traffic numbers are not accurate when running isa.

example

when you want to change your cache in isa, you will need to change to code that controls the asp page. in

order to turn cachecontrol off, you will need to reprogram your asp pages by adding:

<%

response.addheader "cachecontrol","public"

%>

you also need to tell the proxy when the page expires so that it can refresh the cache appropriately. add

this line to set the cache period to 1 hour:

<%

response.expires = 60

%>

microsofts security and internet acceleration server can be used for caching web pages if you dont mind

recoding your site, however other caching systems handle dynamic pages better, such as microsofts asp+

and post points xcache.

active server pages plus

asp+ is an extension of microsofts active server pages. this completely new approach to active server

pages is scheduled to be release in early 2001. basically, asp+ is a set of tools that extends the

microsoft internet information services (iis) server. however, unlike other asp upgrade paths, you need to

recode your current asp pages to take advantage of microsofts new "managed code" scripting languages and

asp+ features. if you do recode your web site, you can add a directive to each page to cache it.

asp+ provides two types of page caching: one called output caching that caches a whole page for a period

of time, and another called partial page caching that caches just a portion of the page or several

portions. both require you to recode each page you want to cache adding the correct directive.

the concept of partial page caching is a very powerful tool, since pieces of the page might stay the same

no matter what user is viewing the page and other pieces might be different on a per-user basis. partial

page caching allows you to put your most expensive routines in a long-term cache and leave your banner

rotation and personalization pieces of the web site completely dynamic.

advantages

asp+ provides both output page caching and partial page caching for free. it allows you to divide your

cache by the browsers language and browser type. this gives you a bigger cache, however if you are

creating unique pages by language or browser type, this is a big benefit.

disadvantages

asp+ requires that you recode your asp pages in order to take advantage of the new asp+ features.

microsoft also requires that you add directives to the top of the page in order to cache. asp+ is in beta

and will launched in early 2001.

example

the following output caching directive is applied to the top of the page:

<%@ outputcache duration="60" %>

because asp+ is still in beta, microsoft has not yet released details on the syntax for the partial page

cache directive.

xcache

xcache is a third-party tool from post point software ( http://www.postpointsoft.com) that allows you to

cache active server pages in iis 4.0 or iis 5.0. unlike asp+, it is currently available. it was released

in may 2000. like asp+, xcache has the ability to perform output caching and partial page caching —

called active caching.

xcache installs on your web server, handling requests before they reach the web server. in this regard it

is much like a reverse proxy server. however, unlike a reverse proxy server, xcache makes sure all

requests that are served from the cache are reflected in your log files. this can be a problem with other

caching solutions that are not on the box — when requests are served from the cache, hits are not logged.

this makes analyzing your web site traffic impossible.

to start using xcache, install it on your web server and start it from the mmc snapin that is provided.

you can pick and choose those pages you want to cache, leaving pages that change on a per-user basis

uncacheable.

advantages

xcache doesnt require recoding to do output caching and provides partial page caching. requests severed

from the cache are logged to the web server log files. xcache is currently available.

disadvantages

xcache uses a disk cache to hold files instead of a ram cache like the isa server.

example if you want to implement active caching (partial page caching), just turn it on from the web site

properties page. once you have it enabled, you can choose which section of the page you dont want to

cache by changing the delimiters from <% %> to <$ $>. xcache will then cache everything in <% %> and leave

everything in <$ $> to execute when the user requests the page.

xcache also allows you to include pages when the file is cached by using the standard #include or include

pages when the page is requested using #dynamic. for example, changing:

<!– #include virtual="/dir/include.asp"–>

to

<!– #dynamic virtual="/dir/include.asp"–>

will make all the code in include.asp execute when the page is requested. includes left in

<!– #include virtual="/dir/include.asp"–>

will execute when the page is cached.

performance gains

you can see significant performance gains using isa, asp+, or xcache, depending on the scenario. imagine

you have hundreds of graphics on your web server that are taking the majority of the servers processing

time and bandwidth. you could cache these with the isa server, reducing the load on the web server and

allowing it to process more asp pages. at the same time the isa server would load the graphics into

memory, serving them faster than the web server could from the hard drive.

now image you have a product catalog in your sql server database of 5,000 products. typically you would

have a category page that lists products in that category and a detail page that displays all the

information about the product. these pages would be driven directly from the database, allowing you to

change and add products easily. now imagine that certain products are not changed for months. this means

that their detail page has not changed. however, every time that page is requested, code has to be

executed and sql server calls have to be made to see exactly the same page that was displayed to the last

user..

in this scenario, caching is the solution. you would cache your detail pages, and all requests would come

out of cache, instead of executing. this would reduce the calls to the sql server and reduce the cpu load

on the web server. pages would return faster and the web server would be able to serve more pages since it

has less work to do.

suppose on the same web site, you have a shopping basket that allows each user to purchase those products

in their shopping cart. in this scenario each user would see a different version of the page since they

would be purchasing different products. you would not want to cache these pages since they change for

every user and the pages need to interact with the database.

however, on the sites home page you have specialty promotions that are based on information you have

tracked about each user. along with these promotions there is a list of all the categories. this page

changes on a per-user basis, however most of the information is the same for all users. this is a perfect

scenario for partial page caching. you could cache the category list, indexes, and navigation, essentially

everything but the promotions — and this would leave the promotions dynamic.

summary

there is a new wave of caching products hitting the market that allow interactive pages to benefit from

web page caching. three of the front-runners are post point softwares xcache, microsofts asp+, and

microsofts security and acceleration server. take a close look at your web site and determine if you

could benefit from dynamic caching.

about the author

wayne berry (wayne@postpointsoft.com ) is the president and ceo of post point software, as a former

microsoft design engineer and one of the top active server page developers in the country, berrys

expertise includes software design, development, marketing and online business. berry served as a software

development engineer at microsoft and as director of development at freeshop prior to post point software.

a popular speaker, berry has been invited to speak to international asp developers conferences, backoffice

conference and internet world. he has authored several technical books, including activex unleashed

programming, windows registry guide, and special edition using microsoft internet information server

4.0. , as well as many articles in print and online trade publications.

berry holds a b.s. in computer science from western washington university.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 动态缓冲
分享到: 更多 (0)