防止IE缓存Ajax调用的最佳方法是什么?

时间:2015-09-16 10:34:51

标签: ajax internet-explorer caching

我正在研究MVC 5 / Jquery项目,我们在IE 10/11上遇到了一个问题。 Internet Explorer正在缓存成功的ajax调用。

我们通过

解决了这个问题

在每个jQuery ajax调用上禁用缓存:

$。ajaxSetup({                 cache:false,                 标题:{                     '缓存控制'' no-cache,no-store,must-revalidate',                     ' Pragma':' no-cache',                     '到期':' 0'                 }             });

禁用服务器端的缓存/控制器:

    // GetFolderDetails is the Action being called through ajax.
    public ActionResult GetFolderDetails(long folderId)
    {
        // Code Here...

        TurnOffResponseCaching();
        return PartialView(PartialView_FolderDetails, selectedFolder);
    }
    private void TurnOffResponseCaching()
    {
        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Cache.SetRevalidation(System.Web.HttpCacheRevalidation.AllCaches);
    }

这两种解决方案都解决了这个问题。

在两者之间,在每次ajax调用上禁用缓存的最佳方法是什么?

0 个答案:

没有答案
相关问题