今天用firefox调试了个统计数据代码没问题,用IE8跑发现取的数据不对,原以为是ExtJs的缓存问题,结果发现是IE缓存的问题。
解决办法有两种:
(1)服务端(未测试asp.net mvc):
public class NoCacheAttribute : ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext context) { context.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); } }
http://stackoverflow.com/questions/264216/getjson-returning-cached-data-in-ie8
(2)客户端(测试OK)
$.getJSON("/Web/Customer/Search/GetViewCount?="+new Date().getTime(), { ids: viewcountIdsStr }, function (data) {
//todo
});