1

Possible Duplicate:
asp.net mvc disable browser cache

how to disable cache for a method in asp.net mvc3?

Problem in IE9 I am saving some data on /home/ page. The page saves data and reload the page to show the newly updated result. In other browsers FF/Opera page refresh is getting new results but on IE9 its showing old data.

Community
  • 1
  • 1
coure2011
  • 40,286
  • 83
  • 216
  • 349
  • 1
    Are you sure it's MVC that's caching the page and not your proxy/browser? How are you accessing the page (GET or POST)? – James Allen Apr 19 '11 at 20:18
  • By default there is no cache in ASP.NET MVC 3, so your question hardly makes any sense without providing more details. Are you talking about browser cache or something? Details please. Are you currently experiencing some problems with a code you would like to share? – Darin Dimitrov Apr 19 '11 at 20:20
  • IE9 does not go back for ajax requests. – coure2011 Apr 19 '11 at 20:56
  • See my prior post at: http://stackoverflow.com/questions/1160105/asp-net-mvc-disable-browser-cache/5546328#5546328 – Adam Tuliper Apr 19 '11 at 20:31

2 Answers2

1
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Vismari
  • 745
  • 3
  • 12
  • If you use this, you may find the following blog useful: [Beware-the-ASP.NET-SetCacheability-method](http://codeclimber.net.nz/archive/2007/04/01/Beware-the-ASP.NET-SetCacheability-method.aspx) – James Allen Apr 19 '11 at 20:35
1

Just reload the page with some random parameter.

Like: /home/?rd=2823772

Make sure to always change the rd parameter to another random number on each reload. This way, IE9 will not have the page cached and it'll refresh like FF/Opera.

  • If user presses back button in IE9 for example, the link will not be random. Anyway a good approach would be using either change the port, so the Action Method gets refreshed. Another way is to either use Outputcache which is limited, or create a NoCacheAttribute for that method. http://stackoverflow.com/questions/1160105/asp-net-mvc-disable-browser-cache – Junior Mayhé Jul 23 '12 at 17:28