Developer .NET UPDATE—brought to you by the Windows & .NET Magazine Network
THIS ISSUE SPONSORED BY
SQL Server Magazine LIVE!
Windows & .NET Magazine LIVE!
Windows & .NET Magazine Events
(below DEVELOPER .NET PERSPECTIVES)
SPONSOR: SQL SERVER MAGAZINE LIVE! AND WINDOWS & .NET MAGAZINE LIVE!LAST CHANCE TO REGISTER FOR SQL SERVER MAGAZINE LIVE!
SQL Server Magazine LIVE! and its sister event, Windows & .NET Magazine LIVE! are set to launch Sunday, May 5, in Palm Springs, CA. Registration will conclude this week, so now is your last chance to get in before the door closes. Two events—more than 100 sessions—for one low price! After just a couple of sessions, you'll be itching to implement the time- and resource-saving tips you've learned. Register at:
April 30, 2002—In this issue:
1. DEVELOPER .NET PERSPECTIVES
- Pay with Cache
- Need 24 x 7 Availability?
- Win a Personal Cinema Card at the Connected Home Virtual Tour
- Featured Thread: The MCSD Certification's New Focus
4. CONTACT US
- See this section for a list of ways to contact us.
1. DEVELOPER .NET PERSPECTIVES
(contributed by Bill Sheldon, firstname.lastname@example.org)
Most people know that when they deal with Internet applications, caching can occur at several levels. Caching can occur at the browser level on the client's machine, at the local-server level on the proxy server or the Web server, and at the ISP level on the ISP's server. No matter the level, caching serves two purposes: to improve the speed at which clients receive data and to reduce the amount of data sent across the network. Unfortunately, when you have dynamic pages or when a user requests a refresh, the entire caching infrastructure gets bypassed because each request must go to the Web server, which again computes and delivers the current data.
What most people don't know is that Microsoft ASP.NET introduces several new types of caching, the first of which is called Output Caching. Aside from providing users with the same end result (i.e., delivering the requested Web page), Output Caching doesn't share the characteristics common to most other cache methods. In particular, Output Caching requires a cache description on each page, doesn't attempt to reduce the amount of data sent across the network, and most important, lets you control what is cached.
The goal of Output Caching is to reduce the servers' workload so that they can return Web pages that are dynamic but aren't in constant flux. A good example of such a Web page is a company-landing page that includes dynamic elements, such as the date and the day's special offers. Updating the underlying page every day isn't realistic, so the Web server would need to compute some elements (e.g., the date) and draw other elements (e.g., the special offers) from a database. Typically, the Web server would have to recompute and redraw these elements for each request. However, with Output Caching, once the Web server has gone through the effort of creating data objects, computing values, and so forth, future requests can reuse the resulting cached page so that the server doesn't have to repeat that work.
Implementing basic Output Caching is easy. All you do is mark the ASP.NET page as dynamic and, at the top of the page, add a directive that tells Microsoft IIS how long it can use the cached Web page for requests. For example, the directive
<%@OutputCache Duration="60" VaryByParam="None" %>
tells IIS to reuse the computed page for the next 60 seconds. (You can specify any time period for the @OutputCache Duration parameter.) Every request during that time will bypass all the database calls and other page calculations and receive the cached page.
The directive I just showed you works great if you want everyone to receive the same Web page. If you want different users to receive different versions of the page, you can refine the caching by setting the directive's second parameter, VaryByParam, to an applicable string. Output Caching supports caching pages based on the query string parameters associated with a request. Thus, you can modify which page to display based on a parameter that's part of the request. In other words, you can return different versions of the page based on such criteria as product category. In addition, Output Caching lets you return different versions based on browser types, HTTP request headers, and custom elements (e.g., cookie values).
But wait, that's not all—if you download ASP.NET caching now, you'll get not only Output Caching but also Fragment Caching. With Fragment Caching, you can precisely control which dynamic data gets cached. If a Web page has a list of specials or other data that's common to all users, you can use Fragment Caching to cache only that part of the page. Taking advantage of Fragment Caching is more involved than using Output Caching because you need to identify the data you want to cache, then use a Web Forms user control to isolate that data from the rest of the page. As part of the user control, you define—in the metadata for your control—an attribute such as
where 60 is the number of seconds to keep this page fragment in cache.
Fragment Caching is wonderful, but even it isn't the end of the ASP.NET caching story. ASP.NET also lets you use cache APIs for application data caching, but I'll save that topic for a future issue. In the meantime, if you're interested in learning more about ASP.NET caching, read the Microsoft article "INFO: ASP.NET Caching Overview" (http://support.microsoft.com/default.aspx?scid=kb;en-us;q307225). If you're interested in learning more about how to use ASP.NET caching directives, go to the Microsoft Developer Network (MSDN) Web site.
Output Caching and Fragment Caching are relatively simple yet powerful tools for scaling your production Web site. In particular, these tools let your Web site better support spikes in user requests without a significant change in response time. IIS can return cached pages literally hundreds of times faster than the time it takes to build a page from its component pieces.
SPONSOR: WINDOWS & .NET MAGAZINE EVENTS
WINDOWS & .NET MAGAZINE ANNOUNCES FALL '02 SCHEDULE
Microsoft ASP.NET Connections, Visual Studio.NET Connections, and SQL Server Magazine LIVE! conferences will be co-located in Orlando, FL, at the beautiful Hyatt Grand Cypress Resort on Oct 27 - 30. Register for one event and gain access to all other sessions for FREE. Immediately following, from Oct 30 - Nov 2, Windows & .NET Magazine LIVE! and XML Web Services Connections will co-locate in the same venue. Deep discounts will be available for those attending the entire week of conferences. Save even more by registering now to lock in your Early Bird discount. For more information, go to
High-availability networks, systems, and applications are crucial to every business. Sign up for our free Webinar taking place on May 24 (sponsored by MKS), and find out how to achieve 24 x 7 availability on Windows 2000. Windows & .NET Magazine author Tim Huckaby shares his expertise on load balancing, monitoring, and more. Register today!
If you think you've already seen the Connected Home Virtual Tour, think again. Browse through the latest home entertainment, home networking, and home automation options and check out our special feature on wiring your home. Sign up for prize drawings, too, and you might win a free personal cinema card, courtesy of VisionTek and nVIDIA. Take the tour today!
When Olivier was reviewing information about the MCSD certification on the Microsoft Web site, he noticed that Microsoft is favoring the Microsoft .NET Framework over C++ and C#. Thus, he's wondering whether an MCSD certification still is of any value if you have a job that doesn't have anything to do with the .NET technology. Join the discussion at the following URL:
4. CONTACT US
Here's how to reach us with your comments and questions:
- ABOUT DEVELOPER .NET PERSPECTIVES — email@example.com
- ABOUT THE NEWSLETTER IN GENERAL — firstname.lastname@example.org
(please mention the newsletter name in the subject line)
- TECHNICAL QUESTIONS — http://www.winnetmag.net/forums
- PRODUCT NEWS — email@example.com
- QUESTIONS ABOUT YOUR Developer .NET UPDATE SUBSCRIPTION?
Customer Support — Developer_dot_NET_update@winnetmag.com
- WANT TO SPONSOR Developer .NET UPDATE?
This weekly email newsletter is brought to you by Windows & .NET Magazine, the leading publication for Windows professionals who want to learn more and perform better. Subscribe today.
Receive the latest information about the Windows and .NET topics of your choice. Subscribe to our other FREE email newsletters.