Exforsys

ASP.NET 2.0

  1. Getting started with ASP.NET 2.0
  2. .NET Framework Fundamentals
  3. Microsoft.NET Framework Tools
  4. Application Development in .NET
  5. What's New in the .NET Framework 2.0 ?
  6. Introduction to Visual Studio.NET
  7. Installing Visual Studio.NET 2005
  8. Working with Visual Studio.NET Web Applications
  9. Whats New in ASP.NET 2.0
  10. Creating an ASP.NET Application
  11. ASP.NET Code Directory
  12. ASP.NET Page Object Model
  13. ASP.NET Server Controls
  14. ASP.NET Working With Master Pages
  15. ASP.NET Creating Content for Master Page
  16. ASP.NET Referencing Master Page Members
  17. ASP.NET Changing Master Pages Dynamically
  18. ASP.NET Creating Nested Master Pages
  19. ASP.NET Working with Web Parts
  20. ASP.NET Using Web Parts and Controls in Web Pages
  21. ASP.NET Web Pages and Layout
  22. ASP.NET - Adding Web Parts at Run Time
  23. ASP.NET Personalization: User Profiles and Themes
  24. ASP.NET Data Access features
  25. ASP.NET State Management
  26. ASP.NET Customizing the Session State Mechanism
  27. ASP.NET State Management And Caching
  28. ASP.NET Security
  29. Forms Authentication in ASP.NET
  30. ASP.NET Managing Membership and Roles
  31. ASP.NET Configuring Page-Level Caching
  32. ASP.NET Setting Application-Level Caching
  33. ASP.NET Data Source Object Model
  34. ASP.NET SqlDataSource Control
  35. ASP.NET Data Bound Controls
  36. ASP.NET GridView Control
  37. ASP.NET GridView Filtering
  38. ASP.NET Adding Sorting and Paging in GridView
  39. ASP.NET DataBound Controls - Details View
  40. ASP.NET Using a Grid to Display Detail Information
  41. ASP.NET Displaying Master-Detail Data on the Same Page
  42. Displaying Master-Detail Data on Separate Pages in ASP.NET
  43. ASP.NET Creating Web Wizards
  44. ASP.NET : Dynamic Image control
  45. ASP.NET Advanced Site Functionality

Ads


Home arrow Technical Training arrow ASP.NET 2.0

ASP.NET State Management And Caching

Page 1 of 2
Author : Exforsys Inc.     Published on: 30th Aug 2005

ASP.NET State Management And Caching

In this tutorial you will learn about Cache Dependency, SqlCache Dependency, New methods added to the CacheDependency Class and The process of writing the cache dependency file.

Ads

The performance of any web application is incumbent upon the amount of server side processing that is required. Web servers must handle individual requests or multiple requests, give quick response time and reduce the load on intermediate and backend data systems. Output caching is regarded as one of the means of reducing server workload. It allows ASP.NET to send its most recent copy of the page to the browser rather than rerunning the code, querying the database and reassembling the page for every request. Cache can be defined as a hashtable used to store frequently accessed data. The data stored is global to the application and is visible within each currently active session.

Application, session and cache have similar structure and API. However, Session is a block of memory set aside for each user while Cache manages globally accessible data. Application and Cache both share application scope but differ from each other in the kind of support they give to item dependencies. An object added to the cache can be configured with file based, key based, time based dependencies. If the associated key changes or the time period expires, the object gets automatically removed from the cache. When the object is removed an event is triggered and code can be written to run on that event and load an updated version to Cache.

Cache is a server based approach to preserving state in an ASP.NET application. The dependency mechanism is encapsulated in the CacheDependency class. This class can represent a single file or directory or an array of files and directories or even items logically related to a particular item and added to the cache. The dependency between a cached item and an external component the developer has to use a specific overload of the Insert method or the Add method.

CacheDependency dep=new CacheDependency(filename);
Cache.Insert(Key.Value.dep);

As stated earlier, if the specified file changes the cached item is automatically removed. This is because the file dependency is based on a file monitor object which is an instance of the FileSystemWatcher class. This is a class that is a managed wrapper around the Windows operating system feature—the file notification change functionality.

Cached items can be bound to other cached items in addition to file dependencies that are created. The item is subordinate to files and folders and arrays of keys. When either of them changes, the item will be invalidated and removed from the cache. If the developer wants to make the item dependent only on the Cache, the file name parameter will have to be set to Null. A number of different combinations with Cache items are supported in ASP.NET 2.0 to create effective dependencies between cached items and other elements. A Cache dependency can be made subordinate to other cache dependencies. This feature comes handy when changes have to be cascaded. Finally ASP.NET 2.0 supports customization of dependencies by making the CacheDependency class inheritable and providing a made to measure SqlCacheDependency cache that provides built in database dependency limited to SQL Server 7.0 and later.

Designing a Cache dependency file is not an easy task. Moreover, the developer must have a very good reason for writing one. Nevertheless, ASP.NET 2.0 makes the process of writing the cache dependency file as comfortable as possible.

Ads

1. The CacheDependency class is inheritable

2. The CacheDependency class picks up all of the base class functionality including constructors that accept array files or create dependencies for other cache items. The developer can review and retain only those constructors which are required by him.

3. The public constructor in the CacheDependency class reduces the amount of coding that needs to be done.

4. The base class handles all the dependencies and all issues relating to synchronization and disposal.

5. The start time feature also need not be framed from point zero. The capacity is inherited from the base class of constructors.

Read Next: ASP.NET Security


 
This tutorial is part of a ASP.NET 2.0 tutorial series. Read it from the beginning and learn yourself.

ASP.NET 2.0

  1. Getting started with ASP.NET 2.0
  2. .NET Framework Fundamentals
  3. Microsoft.NET Framework Tools
  4. Application Development in .NET
  5. What's New in the .NET Framework 2.0 ?
  6. Introduction to Visual Studio.NET
  7. Installing Visual Studio.NET 2005
  8. Working with Visual Studio.NET Web Applications
  9. Whats New in ASP.NET 2.0
  10. Creating an ASP.NET Application
  11. ASP.NET Code Directory
  12. ASP.NET Page Object Model
  13. ASP.NET Server Controls
  14. ASP.NET Working With Master Pages
  15. ASP.NET Creating Content for Master Page
  16. ASP.NET Referencing Master Page Members
  17. ASP.NET Changing Master Pages Dynamically
  18. ASP.NET Creating Nested Master Pages
  19. ASP.NET Working with Web Parts
  20. ASP.NET Using Web Parts and Controls in Web Pages
  21. ASP.NET Web Pages and Layout
  22. ASP.NET - Adding Web Parts at Run Time
  23. ASP.NET Personalization: User Profiles and Themes
  24. ASP.NET Data Access features
  25. ASP.NET State Management
  26. ASP.NET Customizing the Session State Mechanism
  27. ASP.NET State Management And Caching
  28. ASP.NET Security
  29. Forms Authentication in ASP.NET
  30. ASP.NET Managing Membership and Roles
  31. ASP.NET Configuring Page-Level Caching
  32. ASP.NET Setting Application-Level Caching
  33. ASP.NET Data Source Object Model
  34. ASP.NET SqlDataSource Control
  35. ASP.NET Data Bound Controls
  36. ASP.NET GridView Control
  37. ASP.NET GridView Filtering
  38. ASP.NET Adding Sorting and Paging in GridView
  39. ASP.NET DataBound Controls - Details View
  40. ASP.NET Using a Grid to Display Detail Information
  41. ASP.NET Displaying Master-Detail Data on the Same Page
  42. Displaying Master-Detail Data on Separate Pages in ASP.NET
  43. ASP.NET Creating Web Wizards
  44. ASP.NET : Dynamic Image control
  45. ASP.NET Advanced Site Functionality
 

Comments