Best Solution for Caching

后端 未结 9 697
走了就别回头了
走了就别回头了 2020-12-13 11:57

Where is the best place to implement caching in a web based app?

  • At the presentation layer (hope not)?
  • At the Business Logic Layer?
  • At the da
9条回答
  •  醉酒成梦
    2020-12-13 12:02

    I can't speak for ASP.NET specific stuff, but I've generally found that you can cache at each level. Your data tier will cache data responses, your presentation layer may find the need to cache generated presentation elements (e.g., user-specific style sheets), etc. In most cases, the data tier is the heaviest cache user and the other tiers will include an object cache if one is proven to be necessary.

    The hardest part is getting cache invalidation working correctly. Stale caches are a major headache during deployment. Make sure to figure out how you are going to manage the lifetime of each cache object. LRU caches work well for caching static elements based on demand. Most data caches, however, will need an explicit life cycle whether it be based on an expiration timer or tied to some sort of a user session.

提交回复
热议问题