asp.net has two kinds of caching that can be utilized by web applications.
output caching is useful when the contents of an entire page can be cached. on a heavily accessed site, caching frequently accessed pages for even a minute at a time can result in substantial throughput gains. while a page is cached by the output cache, subsequent requests for that page are served from the output page without executing the code that created it.
sometimes it's not practical to cache an entire page--perhaps portions of the page must be created or customized for each request. in this case, it's oftentimes worthwhile to identify objects or data that are expensive to construct that are eligible for caching. once these items are identified, they can be created once and then cached for some period of time.
choosing the time to cache an item can make for an interesting decision. for some items, the data might be refreshed at regular intervals or the data is valid for a certain amount of time. in that case, the cache item can be given an expiration policy that will cause them to be removed from the cache when they're expired. code that accesses the cache item simply checks for the absence of the item, and recreates it if necessary.
the asp.net cache supports file and cache key dependencies, allowing developers to make a cache item dependent on an external file or another cache item. this technique can be used to invalidate items when their underlying data source changes.
新闻热点
疑难解答
图片精选