4

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(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!!

(sorry for my english)

snekkke
  • 441
  • 1
  • 5
  • 15

3 Answers3

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.

kdawg
  • 2,019
  • 21
  • 31
2

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

Atif Aziz
  • 71
  • 7
-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.

mesut
  • 2,099
  • 3
  • 23
  • 35
  • This is untrue. It is stored on the server side. See kdawg's answer. – crichavin Dec 08 '16 at 16:34
  • @ChadRichardson This is not completely untrue. If you add Location = Client, then it will hit controller on each request. It is really strange, because with other Location values it just throws an exception that Location and other values can't be used. So solution is to remove Location=OutputCacheLocation.Client Note: Remember that this works only for child actions. – Yehor Androsov Jan 15 '19 at 10:40