27

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

GEOCHET
  • 20,745
  • 15
  • 72
  • 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,615
  • 24
  • 98
  • 151
DSO
  • 9,283
  • 10
  • 51
  • 58
1

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

pilavdzice
  • 948
  • 8
  • 27