帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP编程
动态缓冲
作者: 发布时间:2005-03-12 来源:
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 caching's 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
Vignette's 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, Microsoft's ASP+, and Post Point Software's 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)

Microsoft's 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 don't 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 Microsoft's 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
Server's 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
%>


Microsoft's Security and Internet Acceleration Server can be used for caching Web pages if you don't mind
recoding your site, however other caching systems handle dynamic pages better, such as Microsoft's ASP+
and Post Point's XCache.


Active Server Pages Plus

ASP+ is an extension of Microsoft's 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 Microsoft's 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 browser's 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 doesn't 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 don't 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 site's 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 Software's XCache, Microsoft's ASP+, and
Microsoft's 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, Berry's
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. 
  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·一个用组件动态创建Excel文件的实  (2005-03-12)
 ·动态输入框的三个函数  (2005-03-12)
 ·动态增加删除物件如(Text,Table)  (2005-03-12)
 ·再论程序的执行速度的问题,(续as  (2005-03-12)
 ·利用OWC服务器端组件动态生成图表  (2005-03-12)
 ·动态产生变量  (2005-03-12)
 ·如何在页面上动态的生成 WebForm  (2005-03-12)
 ·在ASP中改善动态分页的性能  (2005-03-12)
 ·动态Include文件的讨论  (2005-03-12)
 ·利用JS在页面上动态生成直线  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·在ASP中使用数据库
·使用ASP脚本技术
·通过启动脚本来感受ASP的力量
·学习使用ASP对象和组件
·解析asp的脚本语言
·初看ASP-针对初学者
·ASP开发10条经验总结
·ASP之对象总结
·ASP与数据库应用(给初学者)
·关于学习ASP和编程的28个观点
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统