Expiring the Page Output Cache Programmatically
You can remove a page from the cache programmatically by using the Response.RemoveOutputCacheItem()
method. For example, imagine that you are caching a page that displays a list of products. Furthermore, imagine that your website includes a separate page for adding a new product. In that case, you want to remove the first page programmatically from the cache when the list of products is updated.
The page in Listing 29.11 uses a GridView
control to display a list of movies. The page is cached for 1 hour with an <%@ OutputCache %>
directive.
Listing 29.11. MovieList.aspx
The page in Listing 29.12 ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.