i found the best way to implement Output Cache
we have only 2 steps to make it:
step 1
------
define in the Web.config some different cache profiles that u need:
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="profile1" duration="100" varyByParam="param1" />
<add name="profile2" duration="100" varyByParam="None" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
step 2
------
define in your pages the profile that u want to use:
<%@ OutputCache CacheProfile="profile1" %>
now, if we want to check if it works
all we have to is to make aspx page, and to play with his links
and check if the DateTime changed or not
TEST.aspx
<%@ OutputCache CacheProfile="profile1" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<%= DateTime.Now.ToString() %><br />
<a href="?param1=1">1</a><br />
<a href="?param1=2">2</a><br />
<a href="?param1=3">3</a><br />
</form>
</body>
</html>
Another small tip:
for disable the OutputCache(in the development environment for example) add location="None" in the appropriate profile in the web.config in this way:
<add name="profile1" duration="100" varyByParam="param1" location="None" />
No comments:
Post a Comment