$.getJSON returning cached data in IE8

前端 未结 7 1403
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 16:38

I\'m playing around with ASP.net MVC and JQuery at the moment. I\'ve come across behavour which doesn\'t seem to make sense.

I\'m calling JQuery\'s $.getJSON

相关标签:
7条回答
  • 2020-11-29 17:15

    If you're using ASP.net MVC, consider adding an extension method to easily implement no caching like so:

        public static void NoCache(this HttpResponse Response)
        {
            Response.Cache.SetNoStore();
            Response.Cache.SetExpires(DateTime.MinValue);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetValidUntilExpires(false);
    
            Response.Expires = -1;
            Response.ExpiresAbsolute = DateTime.MinValue;
            Response.AddHeader("Cache-Control", "no-cache");
            Response.AddHeader("Pragma", "no-cache");
        }
    
    0 讨论(0)
提交回复
热议问题