【问题标题】:OutputCaching per user per culture, memory performanceOutputCaching per user perculture, memory performance
【发布时间】:2011-07-25 08:53:57
【问题描述】:

我正在开发一个网站,在该网站中,每种类型的用户 ({guest,loggedIn}) 都可以查看不同文化 ({en-US...}) 的 [N] 个页面。我正在使用 GetVaryByCustomString 来处理每个页面的缓存:

Public Overrides Function GetVaryByCustomString(ByVal currentContext As HTTPContext, ByVal customArgs As String) As String  
    Select Case customArgs
        Case "userAndCulture"
            Return String.Format("{0}{1}", Languages.getLanguageID(), User.getUserID(0))
    End Select
    Return MyBase.GetVaryByCustomString(currentContext, customArgs)
End Function

注意:getUserID() 具有 DBNull.Value 的默认“returnValueWhenNull”(它用于大部分工作的 SQL),所以我发送 0(零),所以所有客人都将拥有相同的页面。

但是,我的主要问题是:这种机制不会在内存方面杀死服务器吗?我的意思是,没有潜在的 [loggedInUsersCount] * [culturesCount] * [pagesCount] 页吗?

另一个注意事项:页面仅缓存在服务器内存中

【问题讨论】:

    标签: asp.net performance caching memory localization


    【解决方案1】:

    它不会杀死服务器,因为缓存有一个有限的限制。它不会超过一定的界限。 ASP.NET 实用地管理缓存大小。当内存不足时,它将从缓存中清除最少使用的项目。所以,你是安全的。

    但是将这么多项目放在缓存中意味着您不会给其他数据太多机会保留在缓存中。您应该查看 Windows 性能计数器并检查 ASP.NET OutputCache 命中率,看看您是否真的在输出缓存上获得了良好的命中率。

    【讨论】:

      猜你喜欢
      • 2019-12-16
      • 1970-01-01
      • 2018-11-26
      • 2020-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 2017-11-11
      相关资源
      最近更新 更多