SoFunction
Updated on 2025-04-13

Cache Method Analysis and Practice Example Code Page 2/2


Example <%@ OutputCache Duration="60" VaryByParam="*" %> This example caches the user control for 60 seconds and creates a separate cache entry for each page where the control is located for each change in the query string.

 
<%@ OutputCache Duration="60" VaryByParam="none" VaryByControl="CategoryDropDownList" %> This example caches the user control for 60 seconds and creates a separate cache entry for each different value of the CategoryDropDownList control for each page where the control is located.

 
<%@ OutputCache Duration="60" VaryByParam="none" VaryByCustom="browser" Shared="true %> Finally, this example caches the user control for 60 seconds and creates a cache entry for each browser name and major version. The cache entry for each browser will then be shared by all pages that reference this user control (as long as all pages reference the control with the same ID). Page-level and user control-level output caching is indeed a way to improve site performance quickly and easily, but in which the true flexibility and power of cache is provided through the Cache object. Using Cache Objects, you can store any serializable data object, controlling how cache entries expire based on a combination of one or more dependencies. These dependencies can include time elapsed since the item was cached, time elapsed since the item was last accessed, changes to files and/or folders, and changes to other cache entries, and changes to specific tables in the database after a slight process.
Previous page12Read the full text