1

Is it possible to cache an entire partial view? I can't find any reference on how to actually set the caching attribute in the aspx view itself. I have a navigation div that is in a partial view and that never changes, so would like to cache it.

<html>
<body>

@Html.Partial("_Nav")   

@RenderBody() 
</body>
</html>

_Nav.cshtml:

/* I want to cache this html */
<div id="menu">
...
</div>
Prabhu
  • 12,995
  • 33
  • 127
  • 210

1 Answers1

0

put the partialview in an actionresult and use

[OutputCache(Duration = 3600)]

example

Community
  • 1
  • 1
JC Lizard
  • 1,050
  • 6
  • 17