Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mvc disable ajax cache

I load list of data by using ajax and partial view(ascx) But I have a problem: my response is cached. I try to write Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) in ascx file but it is not helped

In ASP.NET WebForms I've solved this by writing Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) in codebehind. So I'd like to know where can I write Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) to disable cache.

like image 402
takayoshi Avatar asked Nov 01 '10 08:11

takayoshi


1 Answers

Use jQuery?

$.ajax({
 cache:false,
 ...
});

or Controller / Action set OutputCacheAttribute.

OutputCacheAttribute Class (System.Web.Mvc)

like image 106
takepara Avatar answered Sep 24 '22 14:09

takepara