Partial view caching on IE

Viewed 556

I have the following Index action method inside my asp.net mvc web application, but I am facing a caching problem on IE only as the partial view “_PagedSwitchTable” will always be cached . and if some data was modified or deleted then the partial view will keep showing old data

public ActionResult Index(string searchTerm = "", int page = 1)
        {
  string withOutSpace = searchTerm.Trim();
  ViewBag.searchTerm = searchTerm;
  int pagesize;
  bool succeed = int.TryParse(System.Web.Configuration.WebConfigurationManager.AppSettings["TechPageSize"], out pagesize);
  var s = repository.FindSwitches(withOutSpace).OrderBy(a => a.Technology.PartialTag).ToPagedList(page, pagesize);
  populateViewData(s);
            if (Request.IsAjaxRequest())
            {

            return PartialView("_PagedSwitchTable", s);
            }

            return View(s);
        }

So to solve this issue I added an OutputCache to the action method as follow, with a duration of 1 second, which solve the issue

[OutputCache(CacheProfile = "VShort", Location = OutputCacheLocation.Client, VaryByHeader = "X-Requested-With")]

So my question is why IE will cache the partial view even if I do not specify an OutputCache, while firefox and chrome will always show the latest data inside the partial view ?. and is adding an Outputcache the right approach to follow to solve this caching problem on IE ?

0 Answers
Related