C #-Cache OutputCache (i) Basic configuration

Source: Internet
Author: User
Tags microsoft sql server 2005

Tag: Sha PAC indicates expiration dependent Server client href body

This article is based on online & personal Summary

1. Introduction

The outputcache output cache is a mechanism for copying an ASP. NET page that is stored in memory. This behavior helps improve performance and reduces the need for the client machine to render the page by responding to the Web page in a timely manner with the returned cache. If a page takes a lot of time to render, caching can significantly improve performance. However, OutputCache also has great shortcomings, if your site needs to be user-poor custom pages or information, you can not use the cache page to achieve your results. But outputcache supports configuration options, avoids this disadvantage, and its configuration is very powerful.

2. Configure the Local

1) OutputCache can be configured in Webconfig, as a global configuration. Can also be configured on the Controller, action.

Webconfig configuration:

<system.web>    <caching>        <outputCacheSettings>            <outputCacheProfiles>                 <add name="profile" duration=" enabled=" true " varybyparam="*"/>            </outputCacheProfiles>        </ Outputcachesettings>    </caching></system.web>

Controller, Action:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;namespacemvcfilter.controllers{[OutputCache (Duration= -, VaryByParam ="*")]     Public classDefaultcontroller:controller {        //[OutputCache (Duration = +, VaryByParam = "*")]         PublicActionResult Index (stringID) {return  This. Json (DateTime.Now.ToString ("T"), jsonrequestbehavior.allowget); }     }}

3. Detailed Configuration

<%@ OutputCache duration="#ofseconds" Location="Any | Client | downstream | Server | None | ServerAndClient"Shared="True | False"VaryByControl="controlname"VaryByCustom="Browser | customstring"VaryByHeader="Headers"VaryByParam="parametername"varybycontentencoding="Encodings"CacheProfile="Cache Profile Name | "'"Nostore="true | false"SqlDependency="database/table Name Pair | CommandNotification"ProviderName="Provider Name"%>
Configuration parameters Description
Duration Required value.
The number of seconds to represent the page cache. Setting this property, page or user control establishes an HTTP response object for an expiration policy, and automatically caches the output of page or user control.
Location The value of the OutputCacheLocation enumeration, which is the default value of any.
Note:. aspx files are not supported.
Shared User control is shared to different pages. The default is False.
Note:. aspx files are not supported.
VaryByControl A semicolon-delimited list string is used for different user-controlled output caches.
VaryByCustom If the value is =broswer, the browser's different name and version information is cached. If it is a custom string, you will override the GetVaryByCustomString method.
VaryByHeader Changes the cache entry based on the changes in the specified header.
A semicolon-delimited list is used for output caching of different HTTP headers. When this property is set to multiple headings, the output cache contains a different version of the requested document, headers.
The VaryByHeader property is set to allow caching in all HTTP 1.1, not just ASP.
This property does not support user controls.
VaryByParam The name of the variable in Request, which should produce a separate cache entry. "None" means no change. "*" can be used to create a new cache entry for each different array of variables. The variables are separated by ";".
Varybycontentencoding A semicolon-delimited list string is used for different output caches. The VaryByContentEncodings property uses the Theaccept-encoding header to determine that the cached response is a different content encoding service. For more information on how to specify acceptable encoding headers, see section 14.3, Hypertext Transfer Protocol (http/1.1 specification on the Web site.
CacheProfile The name of the cache setting is associated with the page. This is an optional property, which defaults to an empty string ("").
Nostore A Boolean value that determines whether to prevent sensitive information from being stored at level two.
SqlDependency A string value that is used to identify a set of database and table names on a page or control output cache dependency. Note that the Thesqlcachedependency Class monitoring table in the output cache relies on a database, so that when updating items in the table, these items are deleted from the cache using based polling. When you use the notification (Microsoft SQL Server 2005) CommandNotification value, the final SqlDependency class is used to register query notifications with the SQL Server 2005 server.
ProviderName A string value that indicates the custom output cache provider that is being used. For more information, see the Remarks section of this topic and the article extensible with ASP. 4 (VS 2010 and. Scott Guthrie's blog on Net 4.0 series)

Can continue to view my article

C #-Cache OutputCache (ii) cache details

C #-Cache OutputCache (i) Basic configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.