用于子操作的MVC OutputCache:它存储在哪里?

时间:2021-10-19 03:49:59

I'm using OutputCache for caching an horizontal menu and a vertical menu in my app. I usually use something like this in the actions I want to be cached

我正在使用OutputCache缓存我的应用程序中的水平菜单和垂直菜单。我通常在我想要缓存的操作中使用这样的东西

    [OutputCache(Duration=3600, VaryByParam="none", Location=OutputCacheLocation.Client, NoStore=true)]
    public ActionResult ActionName()
    {
        .......
    }

But if it is a child actions i must use

但如果这是我必须使用的儿童行动

    [ChildActionOnly]
    [OutputCache(Duration = 180, VaryByParam = "none")]
    public ActionResult Menu() 
    {
       ......
    }

When you use OutputCache with child actions you can´t specify properties like Location or NoStore. So the question is, if i can´t specify the cache location (client, server, any) for a child action, where is it stored by default?? Thanks!!

将OutputCache与子操作一起使用时,无法指定Location或NoStore等属性。所以问题是,如果我不能为子操作指定缓存位置(客户端,服务器,任何),默认存储在哪里?谢谢!!

(sorry for my english)

(对不起我的英语不好)

3 个解决方案

#1


2  

I'm just guessing here, but it would probably get stored just on the server. The idea of a partial view (likely the result of a child action) being stored on the client doesn't make sense -- the client doesn't have any idea of the page's action break-down on the server.

我只是在这里猜测,但它可能只存储在服务器上。将部分视图(可能是子操作的结果)存储在客户端上的想法没有意义 - 客户端不知道页面在服务器上的操作分解。

The way I see it, unless the entire page is cached, the client must go to the server to get the page rendered, at which point, the server can returned the cache child action result.

我看到它的方式,除非整个页面被缓存,客户端必须去服务器获取页面呈现,此时,服务器可以返回缓存子操作结果。

#2


2  

When we use Output Cache for child action it is cached on Server not on client side.

当我们对子操作使用输出缓存时,它将缓存在服务器上而不是客户端上。

#3


-3  

Unfortunatly it is cached on client, Just set a breakpoint on your childAction Method, and run application from multiple browsers, for each browser ChildAction will called in cache duration.

不幸的是,它被缓存在客户端上,只需在childAction方法上设置断点,并从多个浏览器运行应用程序,对于每个浏览器,ChildAction将在缓存持续时间内调用。

#1


2  

I'm just guessing here, but it would probably get stored just on the server. The idea of a partial view (likely the result of a child action) being stored on the client doesn't make sense -- the client doesn't have any idea of the page's action break-down on the server.

我只是在这里猜测,但它可能只存储在服务器上。将部分视图(可能是子操作的结果)存储在客户端上的想法没有意义 - 客户端不知道页面在服务器上的操作分解。

The way I see it, unless the entire page is cached, the client must go to the server to get the page rendered, at which point, the server can returned the cache child action result.

我看到它的方式,除非整个页面被缓存,客户端必须去服务器获取页面呈现,此时,服务器可以返回缓存子操作结果。

#2


2  

When we use Output Cache for child action it is cached on Server not on client side.

当我们对子操作使用输出缓存时,它将缓存在服务器上而不是客户端上。

#3


-3  

Unfortunatly it is cached on client, Just set a breakpoint on your childAction Method, and run application from multiple browsers, for each browser ChildAction will called in cache duration.

不幸的是,它被缓存在客户端上,只需在childAction方法上设置断点,并从多个浏览器运行应用程序,对于每个浏览器,ChildAction将在缓存持续时间内调用。