Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


Sharepoint TechCon

Reader rating:
Click here to read 1 comment about this article.
Article source: CoDe (2002 - May/June)


Article Pages:  1  2 3 4 - Next >


ASP.NET Caching Strategies

ASP.NET provides developers with the ability to cache dynamically generated pages.This means that it is now possible to cache pages built on posted data and querystrings! For instance, an e-commerce site that generates the same catalog from the database over and over on nearly every user request can now simply cache the catalog pages. Caching saves precious database server CPU cycles and renders pages down to the client much faster. Of course, when the catalog data is updated, the cache can simply refresh itself. Furthermore, developers can define the length of time an item is to be cached, indicate cache dependencies, create cached versions per browser, and indicate where an item should be cached (client, server, proxy, etc.).

"
Caching is one of the greatest new features that ASP.NET provides regarding application performance.
"

There is no doubt that caching is one of the best methods of increasing your Web application's performance. ASP.NET and the .NET Framework provide a set of tools that make implementing caching simple. Data that is used over and over in your application, updated semi-regularly (like a catalog, list of contacts, store locations, etc.) make great candidates for caching. The right caching strategy will no doubt increase throughput on your servers and put smiles on your users' faces. This article describes how to implement caching in your applications using the .NET Framework.

Caching Basics (Output Caching)

Output caching involves the strategy of taking a dynamically generated Web page and caching its content so that subsequent requests for the page are fulfilled from an in-memory cache rather than through the execution of code. In high volume Web sites, the right caching strategy can dramatically improve scalability statistics.

ASP.NET gives developers multiple methods of implementing caching. For the most basic page-level caching, developers can use the declarative API, which is simply the term for defining caching parameters at the top of an ASP.NET page using HTML style tags.

First you need to find a candidate page for caching. For example, suppose that you have a Web-based report that displays monthly sales figures by region for the current year. This report's data is updated infrequently, but regularly, as different regions report at different times. The report is accessed many times by many people throughout the organization. Sounds like a good candidate for caching! To do so, you simply place the following declaration at the top of your ASP page.

<%@ OutputCache Duration="3600"     VaryByParam="None" %>

This declaration instructs the .NET Framework to cache this Web page for a specified number of seconds (in this example, the page will be cached for 3600 seconds, or one hour). Requests made for the page during this time are returned from cache. The page does not execute its code to satisfy these requests, but instead uses in-memory results, thus conserving server resources and increasing page response times.

This declarative API allows you to indicate a simple and effective caching strategy for most of your pages. However, for developers who want more control over caching within their code, ASP.NET also provides a programmatic API. This API is a set of classes, methods and properties that wrap the caching features exposed by the .NET Framework. These classes enable you to set caching directives from within your ASP.NET applications. For example, the caching directive in the previous example could also be indicated programmatically by the following code:

Page.Response.Cache.SetExpires(Now.AddHours(1))

This code can be added to your code-behind class inside your Page_Init or Page_Load method. Notice that we call the SetExpires method to indicate a date on which the cached page should expire (again, one hour in our example).

This article will walk you through the classes related to caching with ASP.NET. It will further explore different caching strategies. It will also discuss updating the cache, removing items from the cache, and setting cache dependencies.

&

By: Lars Powers

Lars has over 12 years of experience designing and implementing solutions on the Microsoft platform. He is the co-author of Visual Basic Programmer's Guide to the .NET Framework Class Library (SAMS Publishing).

larspowers@hotmail.com

By: Mike Snell

Mike has over 12 years of experience writing and designing software. His broad range of experience covers creating enterprise-level, Web-based systems as well as commercial applications using the Microsoft platform.

mike@brilliantstorm.com

Fast Facts

Caching inside ASP.NET can greatly improve your application's performance.



Article Pages:  1  2 3 4 - Next Page: 'The Namespaces (System.Web and System.Web.Caching)' >>

Page 1: ASP.NET Caching Strategies
Page 2: The Namespaces (System.Web and System.Web.Caching)
Page 3: Fragment Caching (Page Portions / User Controls)
Page 4: Caching Dependencies

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.7 out of 5

3 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      Sharepoint TechCon

 

SSWUG