|
For most data-driven Web sites, caching
can be a thorny topic, especially when a situation demands
the need for caching and the necessity of up to date data.
In ASP.NET 1.x, pages could be cached for a length of
time and organized by input parameters (querystring or
POST parameters):
EXAMPLE:
<%@ outputcache duration="3600"
varybyparam="PRodID" %>
The code in Listing 5 caches a page in
memory for one hour based on the variable ProdID. The
problem that arises in the above example is what to do
if relevant business data is updated elsewhere. For example,
consider a product catalog page cached by product ID.
If information about this product (quantity available
or price, for example) is updated from an administrative
site, incorrect data is cached and displayed to customers.
With the previous version of ASP.NET, the solution to
this problem would require either manually removing the
page from cache using Response.RemoveOutputCacheItem,
or waiting until the duration time expires and allowing
the system to update the page automatically.
|