当我的一个商品页面进行了缓存后,
在后台添加了新商品,
但因为前台已经缓存了,
用户刷新看不到. 
那怎么去清空这些缓存呢注意:还有另一个要求,因为我的特价商品表没有进行更新
所以这个页面的缓存我不想清空,
而是想清楚商品列表的缓存也就是当我更新某些东西后我想要指定的缓存失效谢谢

解决方案 »

  1.   

    <%@ OutputCache   Duration="600"   VaryByParam="*"%>
    现在只限VaryByParam和Duration这两个参数
    是否还有哪个参数指定关键字
    然后再有一个方法像OutputCache.Remove("关键字")??
    这样的吗
      

  2.   

    http://msdn.microsoft.com/zh-cn/library/ms178604.aspx
      

  3.   

    设置一个DependencyObject,每次增、删、改时把这个DependencyObject remove掉。
      

  4.   

    sorry,是CachDependency对象。
      

  5.   


    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="UC_List.ascx.cs" Inherits="UserControl_UC_List" %>
    <%@ OutputCache Duration="600" VaryByParam="*" %>那我这样生成的了缓存 在程序代码中如何来删除呢 谢谢
      

  6.   

    这不能通过@output完成,但可以在不改变@output的前提下在Page_Load添加以下语句完成:
    Response.AddCacheDependency(new SqlCacheDependency(sqlCommand))其中sqlCommand必须是一个SelectCommand,当它的结果集发生改变时,你的页面cache自动会失效。
      

  7.   

    要善用缓存,缓存是把双刃剑怎么还没有解决?清除全部缓存    Protected Sub RemoveAllCache()        Dim _cache As System.Web.Caching.Cache = HttpRuntime.Cache
            Dim CacheEnum As IDictionaryEnumerator = _cache.GetEnumerator()
            Dim al As New ArrayList()
            While CacheEnum.MoveNext()
                al.Add(CacheEnum.Key)
            End While        For Each key As String In al
                _cache.Remove(key)
            Next
        End Sub
    清除页面缓存HttpResponse.RemoveOutputCacheItem("/default.aspx")