0

Im working with MVC 3 and Currently this is my code that needs to not be Cached and it shared among several views

   <div id="logindisplay">
    <h2> Welcome <strong><%= Context.User.Identity.Name %></strong></h2>
 </div>

all my pages have this at the top that includes the master view that has this in it

%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

And finally, all my controllers have this in it on the Index() action

 [OutputCache(Duration=60*60*24)]
        public ActionResult Index()
        {               
            return View();
        }

some of my partial views have it too

my question is what is the best way of implementing a partial caching/donut caching kind of thing here? I'd like to use other open source libraries as a last resort because if there is a more simple solution out of the MVC 3 box, I don't know it and would appreciate your help!!!

UPDATE since i am unable to answer my own questions right now

So I used this attribute on OutputCache instead. Apparently it should work, since my problems were stemming from it being cached on the server side, and that line of code that I do not want cached is evaluated on the server side!

[OutputCache(Location = OutputCacheLocation.Client,Duration = 60 * 60 * 24)]
egucciar
  • 2,039
  • 6
  • 23
  • 24

1 Answers1

0

ASP.NET MVC 2 and 3 doesn't support donut caching. It was possible back in ASP.NET MVC 1 but support for it has been removed in ASP.NET MVC 2. Here's a very nice article that illustrates one possible way to implement it.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    Also see my previous question which Darin was kind enough to answer: http://stackoverflow.com/questions/4685906/is-donut-caching-available-in-asp-net-mvc-3 – JP. Apr 24 '12 at 15:56
  • hmm, yes, I read about this. I guess my confusion stems from the fact that the call to the data I do not wish to cache is made directly in the Server Tags, and isn't part of a controller action, so even if I made the effort to leverage the Nuget Donut caching (I read that article, thought it answered my prayers, then realized I did not know how to go about implementing it for this specific case) I'm not sure how it being data in the Server Tags effects the ability for you to exclude it so easily using the donut cahcing described here – egucciar Apr 24 '12 at 16:05