@ outputcache command to the following:
Use the @ outputcache commandUse the @ outputcache command to implement general requirements for page output cache. @ Outputcache command the header Declaration of the user control contained in the ASP. NET page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ Outputcache command DeclarationCodeAs follows.
@ Outputcache command code
As shown above, the @ output
CacheDependency: allows you to create dependencies Based on files or other caches.
SqlCacheDependency: SQL Server-based tables or SQL Server-based Query Dependencies
AggregateCacheDependency: dependencies Based on Multiple cache dependencies. For example, you can combine both SQL dependencies and file dependencies.
7. Configure SQL cache Dependencies
Use the dependent data library and a single data table, and use the aspnet_regsql.exe command line tool for configuration.
Configure database supp
during a request:Response.Cache.SetNoStore ();
ProviderName
A string value that identifies the custom output-cache provider to use.
This property is supported only in user controls (. ascx files). It is not supported by the @ OutputCache directive contained in an ASP. NET page (. aspx file).
Shared
A Boolean value that determines whether the user control output can be shared by multiple pages. The default value is False.
are inherited and enhanced in ASP. NET 2.0. The page output cache API mainly refers to the httpcachepolicy class.@ OutputcacheControl the output cache policies of user controls contained in ASP. NET pages or pages in a declarative manner.Syntax:Location = "any | client | downstream | Server | none |
Serverandclient"
Shared = "True | false"
Varybycontrol = "controlname"
Varybycustom = "browser | customstring"
Varybyheader = "headers"
Varybyparam = "parametername"
Cacheprofile = "cache profile na
the default. aspx. VB code:
Private sub page_load (byval sender as object, byval e as system. eventargs) handles me. LoadLabel1.text = ctype (system. datetime. Now (), string)End sub
Next, configure the Web. config file. The configuration file we use is as follows:
Note that the polltime parameter is millisecond and the minimum value is 500. In this parameter, set the system time to check whether the data in the cache needs to be updated. The
Finally, in the prog
Use the @ outputcache command
Use the @ outputcache command to implement general requirements for page output cache. @ Outputcache command the header Declaration of the user control contained in the ASP. NET page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ Outputcache command DeclarationCodeAs follows.
@ Outputcache command code
As shown above, the @ outputcache command contains 10 attributes, incl
user control contained in the ASP. NET page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ Outputcache command DeclarationCodeAs follows.
Cacheprofile= ""Nostore ="True | false"Duration= "# Ofseconds"Shared= "True | false"Location= "Any | client | downstream | Server | none | serverandclient"Sqldependency= "Database/table name pair | commandnotification"Varybycontro
enhanced in ASP.net 2.0. The page output caching API mainly refers to the HttpCachePolicy class.
Using the @ OutputCache directive
With the @ OutputCache directive, you can implement a general need for page output caching. The @ OutputCache directive declares the head of a user control contained in a ASP.net page or page. This approach is very convenient, with just a few simple property settings, you can implement the page's output caching strategy. The @ OutputCache directive declares the fo
cache, sets a portion of the page to not be cached, so that, while the entire page is cached, the page is processed again when it is requested again, which is not set to the cached content. Using the @ OutputCache directiveThe @ OutputCache directives for control caching and page output caching have similarities and differences. The common denominator is that they are set in the same way, with the @ OutputCache instruction string that contains the properties at the top of the file. The differe
access accountGRANT SUBSCRIBE QUERY notifications to test Note: This step is very important, if there is no permission, the database changes the notification will not be received, the cache will never be refreshed, I started to use the SA account, life and death are not refreshed, it took me two days to debug the problem, or can not grant this permission to SA (Ms Forbidden), so, change the database access account can be . 4. Check for previous cache errors Hide Line number copy code ? This i
Using the @ OutputCache directiveWith the @ OutputCache directive, the general need for page output caching can be achieved. The @ OutputCache directive declares the header of the user control contained in an ASP. NET page or page. This is a convenient way to implement a page's output caching strategy with just a few simple property settings. The @ OutputCache directive declaration code is as follows.@ OutputCache Instruction CodeAs shown above, in the @ OutputCache directive, there are 10 prope
1. Replace CacheYou can use substitution to dynamically update the cache page.[Csharp]Public static string GetTime (HttpContext context){Return DateTime. Now. ToString ();}
Aspx[Html]Cached Time:
Finally, enable cache output on the page.Result: The Page Time is different each Time. The cached Time is updated every 5 seconds.Tips: Disable cache output[Csharp]This. Response. Cache. SetNoServerCaching ();2. Data DependencyDepending on the database page and associated with the corresponding SQL sta
"Varybycontrol = "controlname"Varybycustom = "browser | customstring"Varybyheader = "headers"Varybyparam = "parametername"Cacheprofile = "cache profile name | ''"Nostore = "True | false"Sqldependency = "database/table name pair | commandnotification"%> Attribute Duration: the cache time for pages or user controls (in seconds ). Note: Required attribute . If this attribute is not included, a analyzer error occurs.Location: Specifies the location of th
speed.
Of course, the above is my personal opinion. If you have any questions, please correct them.
ASP. NET provides a convenient way to control the cache. @ OutputCache command can be used to control the page output Cache
OutputCacheSyntax:
Location = "Any | Client | Downstream | Server | None |ServerAndClient"Shared = "True | False"VaryByControl = "controlname"VaryByCustom = "browser | customstring"VaryByHeader = "headers"VaryByParam = "parametername"VaryByContentEncoding = "encodings"Cac
Series directory:
Sqldependency Cache Usage
Asp.net uses sqldependency
Sqlcachedependency use command notifications to invalidate Cache
Cachedependency usage
Aggregatecachedependency usage
Sqlcachedependency uses Round Robin to invalidate Cache
Bytes -------------------------------------------------------------------------------------------------
In SQL Server 7 and later versions, the rotat
for new records in the database table and must be processed immediately. To do this, the program queries the table multiple times within 1 seconds to find the unhandled record. This can be resolved by inserting data from the program's asynchronous calls to and from the table, or by using the SqlDependency in the. NET Framework. (SqlDependency provides the ability to automatically update the data (or cache)
, the program queries the table multiple times within 1 seconds to find the unhandled record. This can be resolved by inserting data from the program's asynchronous calls to and from the table, or by using the SqlDependency in the. NET Framework. (SqlDependency provides the ability to automatically update the data (or cache) by SqlDependency triggering an onchang
complete.Enable the table for the SQL cache dependency.
Then, set up some information related to SqlDependency (for example, polling time), which is set in Web. config:Connectionstringname= "NorthwindConnectionString"Polltime = "/>"The name is only required to be a convenient memory name (usually the name of the database), Polltime is the polling time (unit: milliseconds).[Quote from MSDN: The small Polltime value increases the number of request
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.