Getting started with ASP. net2.0 Cache Technology
Source: boke.com
ASP. net2.0 provides the following caching methods:
Output caching
Fragment caching
Data Cache
SQL Cache
Cache Configuration
1. output caching:
When a webpage is frequently accessed, We Can cache the entire webpage to improve efficiency. When the user accesses the webpage, the formatted HTML is directly sent to the client.
<% @ Outputcache duration = "120" varybyparam = "NONE" %>
2. Parameter cache:
Pages are generated based on user requests. There are only a limited number of combinations of user requests. The table caches content based on parameters.
<% @ Outputcache duration = "120" varybyparam = "state" %>
<% -- <A href = "default. aspx? State = Ca "> </a> -- %>
3. Hard disk cache:
By default, the output cache is cached on the hard disk. You can modify the diskcacheenable attribute to set whether the cache is cached. You can also configure the cache file size in Web config.
4. Page fragment cache:
The content on the page is dynamically updated based on the request, and most of the content can be cached. (If multiple controls need to be cached, they can be used as one user control)
<% @ Outputcache duration = "120" varybycontrol = "controlid" %>
<Center> </center>
5. cache data:
We recommend that you enable the hard disk cache for a longer cache time because of Io overhead.
Dataset DS = new dataset ();
DS = cache ["restaurant"];
If (DS = NULL)
{
DS = resdataset;
Cache ["restaurant"] = Ds;
}
6. SQL dependency
Configure the SQL cache of the database server and then reference it on the page
<Center> </center>
7. cache configuration (reduce repeated definitions)
A. Web. config Definition
<Center> </center>
B. Page call
<% @ Outputcache cacheprofile = "cachefor60seconds" varybyparam = "name" %>
<Table width = "90%" border = "0" cellpadding = "0" cellspacing = "0" align = "center">
<Tr> <TD> <B> popular recommendations </B>: </TD>
<TD> <a href = "http://www.enet.com.cn/article/2007/1210/A20071210942740.shtml" target = "_ blank"> <font size = 2 color = Red> invincible command to delete files that cannot be deleted
</Font> </a> </TD>
<TD> <a href = "http://www.enet.com.cn/article/2007/1211/A20071211943925.shtml" target = "_ blank"> <font size = 2 color = Red> 7 tips for Windows anti-Black attack </font>/ a> </TD>
</Tr> </table>