Where should caching occur in an ASP.NET MVC application?

前端 未结 6 2035
有刺的猬
有刺的猬 2021-02-07 12:14

I\'m needing to cache some data using System.Web.Caching.Cache. Not sure if it matters, but the data does not come from a database, but a plethora of custom obj

6条回答
  •  粉色の甜心
    2021-02-07 12:44

    It all depends on how expensive the operation is. If you have complicated queries then it might make sense to cache the data in the controller level so that the query is not executed again (until the cache expires).

    Keep in mind that caching is a very complicated topic. There are many different places that you can store your cache:

    • Akamai / CDN caching
    • Browser caching
    • In-Memory application caching
    • .NET's Cache object
    • Page directive
    • Distributed cache (memcached)

提交回复
热议问题