2010-02-25 20 views
5

我正在尋找一種僅爲匿名用戶配置緩存的方法。我期望這樣做的原因是當用戶登錄並創建內容時,他們不會立即看到內容。在我們的舊系統(linux/php/mysql)中,我們將它配置爲只緩存匿名用戶,這不是問題。僅爲匿名配置ASP.NET緩存?

現在,我們有在web.config緩存設置這樣

<caching> 
    <outputCacheSettings> 
    <outputCacheProfiles> 
     <add name="High" duration="60" varyByParam="*" enabled="true"/> 
     <add name="Medium" duration="30" varyByParam="*" enabled="true"/> 
     <add name="Low" duration="10" varyByParam="*" enabled="true"/> 
    </outputCacheProfiles> 
    </outputCacheSettings> 
</caching> 

我知道,我可以添加一個VaryByCustom是=「username」的像this post在談論。但是這並不能解決我的問題。它仍然緩存用戶登錄並存在相同的問題。

回答

0

您可以刪除/當用戶使用該方法來改變它從緩存中過期的頁面如下圖所示:

HttpResponse.RemoveOutputCacheItem("/PageJustUpdated.aspx"); 
1

正如詹姆斯說,它可能會更好緩存以某種方式無效。

這樣你就可以爲所有的用戶匿名維護一個緩存。爲什麼不爲你的管理員提高響應能力,畢竟他們最終會使用應用程序呢?

你看過SQL緩存依賴性嗎?這樣,當存儲內容的表被改變時,緩存就會失效。

http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx