I am trying to use the OutputCache
attribute in my MVC app and it doesn't appear to work when I use OutputCacheLocation.Client
:
public class HomeController : Controller
{
[OutputCache(Duration=15, Location=OutputCacheLocation.Client)]
public ActionResult Client()
{
ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss");
return View();
}
[OutputCache(Duration=15, Location=OutputCacheLocation.Any)]
public ActionResult Any()
{
ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss");
return View();
}
}
The first one does not cache. I hit the page every second and it changes the time. The second one works. It only changes the time every 15 seconds. Is there something I am missing? I'm debugging this using IE8 and the built in development server in Visual Studio.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…