27

What is the proper (browser agnostic) way to disable page caching in ASP.NET MVC?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
kjgilla
  • 1,227
  • 3
  • 12
  • 13

2 Answers2

49

Try this:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public ActionResult NonCacheableData()
{
    return View();
}
Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
dso
  • 9,463
  • 10
  • 53
  • 59
1

If your MVC Action returns JSON instead of HTML such as in an ajax call you cannot use the meta-tag approach.

pilavdzice
  • 958
  • 8
  • 27