ASP.NET MVC - caching pages on client side

孤街醉人 提交于 2020-01-10 03:18:46

问题


I have code that is cached this way:

[OutputCache(Duration="3600", Location=OutputCacheLocation.Client)]

Now, I don't exactly know how this output cache works. Where exactly does it keep the copy of a page? And what are the differences between OutputCacheLocation.Client and OutputCacheLocation.Browser?


回答1:


Where exactly does it keep the copy of a page?

The location of where the cache is stored is determined by Location property of the OutputCacheAttribute. In your case you set Location=OutputCacheLocation.Client so it will keep the cache on the client browser.

And what are the differences between OutputCacheLocation.Client and OutputCacheLocation.Browser?

OutputCacheLocation.Browser doesn't exist. It's an invalid value. The documentation of the OutputCacheLocation enumeration type contains the possible values along with a description of its usage:

  • Any - The output cache can be located on the browser client (where the request originated), on a proxy server (or any other server) participating in the request, or on the server where the request was processed. This value corresponds to the HttpCacheability.Public enumeration value.
  • Client - The output cache is located on the browser client where the request originated. This value corresponds to the HttpCacheability.Private enumeration value.
  • Downstream - The output cache can be stored in any HTTP 1.1 cache-capable devices other than the origin server. This includes proxy servers and the client that made the request.
  • Server - The output cache is located on the Web server where the request was processed. This value corresponds to the HttpCacheability.Server enumeration value.
  • None - The output cache is disabled for the requested page. This value corresponds to the HttpCacheability.NoCache enumeration value.
  • ServerAndClient - The output cache can be stored only at the origin server or at the requesting client. Proxy servers are not allowed to cache the response. This value corresponds to the combination of the HttpCacheability.Private and HttpCacheability.Server enumeration values.


来源:https://stackoverflow.com/questions/14609291/asp-net-mvc-caching-pages-on-client-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!