Is there anyway to disable cache on a action of a returned view? By using an attribute or something? The reason for this is that IE9 and below seem to always cache my views/partial views, so I'd like to prevent that for some actions
- 
        Do you mean browser cache or server cache?jorgebg– jorgebg2012-01-20 13:16:36 +00:00Commented Jan 20, 2012 at 13:16
- 
        Both! I think i've done it with browser cache using JQuery, but Server cache is what I want to disableCallumVass– CallumVass2012-01-20 14:23:01 +00:00Commented Jan 20, 2012 at 14:23
                    
                        Add a comment
                    
                 | 
            
                
            
        
         
    1 Answer
Putting this attribute on an action should do the trick:
[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0)]
7 Comments
CallumVass
 It tells me that duration must be a positive number, so should I just set it to 1? Cache of 1 second should be fine i think?
  jgauffin
 +1 I edited the post, NoStore instead of VaryByParam. Hope you don't mind.
  jgauffin
 @BiffBaffBoff: 0 means that no cache should be used.
  Kristof Claes
 @jgauffin Not all! I've used 
  [OutputCache(Duration=0, VaryByParam="None"] in the past and it worked for me, but after reading the MSDN docs, your solution actually makes more sense.CallumVass
 This doesnt work: System.InvalidOperationException: Duration must be a positive number. So I've set Duration = 1, 1 second shouldnt cause any harm
   |