简体   繁体   English

ASP.NET MVC缓存和IoS野生动物园

[英]ASP.NET MVC caching and IoS safari

I have a Controller like 我有一个像

[OutputCache(Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "category", Duration = 60)]
    public ActionResult Search(string keywords, string location, string category)
    {

//... return View etc.. } // ...返回视图等。}

and ajax request on this view 和ajax请求对此视图

function refreshPager(pageNum, nextOper) {
    $.ajax({
        url: String.format("/Adv/GetPagesData?currentPage={0}&SortBy={1}&keywords={2}&location={3}&country={4}&category={5}&minPrice={6}&maxPrice={7}&type={8}&condition={9}", pageNum, $("#SortBy option:selected").text(), $("#keywords").val(), $("#id-location").val(), $("#Country option:selected").val(), $("#search-category option:selected").val(), $("#minPrice").val(), $("#maxPrice").val(), $("#ajaxTabs li[class='active']").attr("id"), $("#condition option:selected").val()),
        method: 'GET',
        datatype: 'json',
        data: { query: 'test' },
        success: function (pdata) {
            pagedata = pdata;
            maxPages = pdata.length;
            if (pageNum < 1) pageNum = 1;
            if (pageNum > maxPages) pageNum = maxPages;
            currentPage = pageNum;
            ko.mapping.fromJS(pagedata, {}, viewModel.PagedItems);
            $(".pageItem").removeClass("selectedItem");
            $(".pageItem:eq(" + pageNum + ")").addClass("selectedItem");

        }
    }).fail(function () { alert('Ошибка получения данных, попробуйте еще раз') }).success(function () {
        count = 0;
        $('.pager-btn').each(function (index, el) {

            if (el.innerHTML == pageNum) {
                $(el.parentNode).addClass("active");
                count++;
            }
        });
        if (count == 0) {
            $('#NotFound').show();
        } else {
            $('#NotFound').hide();
        }
        nextOper(currentPage);
    });
}

thats fine works in all Windows browsers but fails in IoS Safari. 多数民众赞成在所有Windows浏览器中都能正常工作,但在IoS Safari中失败。 When caching attribute is off then it's ok in Safari too. 如果关闭了caching属性,那么在Safari中也可以。 May be someone got that problem too? 也许有人也遇到了这个问题?

The following will prevent all future AJAX requests from being cached, regardless of which jQuery method you use ($.get, $.ajax, etc.) 无论您使用哪种jQuery方法($ .get,$。ajax等),以下内容都将阻止所有以后的AJAX请求被缓存。

$.ajaxSetup({ cache: false });

Reference Link : https://stackoverflow.com/a/7750483/3041974 参考链接: https : //stackoverflow.com/a/7750483/3041974

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM