What Are the Patterns and Best Practices for Caching in ASP.NET?

前端 未结 3 1392
花落未央
花落未央 2020-12-23 00:22

We are working on a large legacy application and we\'re redesigning the business layer and the data layer. We believe that it is a good time to redesign the way cache is han

3条回答
  •  滥情空心
    2020-12-23 00:41

    This is a big subject, but here are a few suggestions:

    1. Don't cache data that's unlikely to be reused, such as user-specific data
    2. Cache at all tiers: client, Silverlight (isolated storage), proxies, http.sys, IIS, ASP.NET cache object, ASP.NET per-request cache, SQL Server
    3. Use SqlDependency / SqlCacheDependency when you can, but don't over-use
    4. Avoid session state; use cookies instead when you can
    5. Leverage page and control (fragment) output caching
    6. Consider using cache validation when needed
    7. Consider light-weight alternatives to the ASP.NET cache object, such as weak memory refs
    8. When used correctly, SQL Server can act as a large cache

    In case it helps, I cover this subject in detail in my book: Ultra-Fast ASP.NET.

提交回复
热议问题