Understanding Caching in .NET
After creating the .NET web applications, the users can access the data of the application either from the server resource i.e. from outside the application such as data stored in a database or from within the application. If the user tries to retrieve data from outside the application, then this process requires more time and steps to perform. Moreover, there is a great deal of bottlenecks such as user traffic, network latency, and database server ability to process the request that are merely time-consuming.
In ASP we did not have efficient caching options that are there now with ASP.NET. The .NET provides the ability to access the applications data from within the application thereby saving the users time. The .NET caching is the process where all the commonly accessed data are stored into memory, i.e. down between the request/response streams, for easy subsequent retrieval. Caching in .NET allows you to store the page output or application data for a short period either on the client or on the server. This page or data could then be used again for subsequent requests thereby avoiding the overhead in re-creating the same data. Caching is specifically preferred when multiple users want to view or use the same information in the same format again and again.
.NET provides three types of caching that can be used to create highly efficient web applications. They are Output caching, Fragment caching, and Data caching. Output caching, otherwise called as page caching, places the pages output into the ASP.NET cache for a specified duration so that the code that had generated it does not have to be run repeatedly for subsequent requests. If the user requests for the cached page during a specified period, then the user views only the cached version of the page.
Though output caching is enabled by default, the page will not be cached unless the page have a valid duration or validation policy and also have a page cache visibility. This type of caching can be set either at the design time by using @OutputCache directive or at runtime by using Response.Cache object. Data caching is used to programmatically store frequently used or expensive data such as data sets into ASP.NET cache for quick access. Subsequent requests for the similar data are supplied directly from the in-memory cache. The data cache expires automatically or at the time specified by you whenever the data is modified in the database.
Fragment caching is somewhat similar to output caching in that instead of caching the entire page fragment caching allows you to cache a portion or fragment of the page. Fragment caching is best suited for pages that have built-in personalization. This means that the personalized pages will constantly change, depending on the user, and fragment caching will allow you to cache only portions of the page that are not personalized, thus, increasing the efficiency of the web application.
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.
Copyright - © 2004 - 2023 - All Rights Reserved.