여기에 설명 할 수없는 것이 있습니다.C# WebMethod로 HTTP_POST jQuery Ajax 요청 결과 캐싱
클라이언트에서 브라우저에 캐시하려는 큰 JSON 데이터 세트가 있습니다. jQuery AJAX를 사용하여 C# 웹 메서드를 호출하고 있습니다.
[System.Web.Services.WebMethod]
여기에 jQuery를 없습니다 :
Cache-Control no-cache
Content-Length 919527
Content-Type application/json; charset=utf-8
Expires -1
모든 설정 :
$.ajax({
url: "/Ajax/ItemAffinity.aspx/FetchAffinityItems?ItemID=" + escape($("#SearchSelectedPageID").val()),
type: "POST",
data: "{}",
cache: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
//contentType: "application/json; charset=utf-8",
success: function (data) {
//do cool stuff
}
});
을 아무리 웹 메소드 내 서버에서 지정한 것, HTTP 헤더는 항상이처럼 보이는 돌아와 나는 webservice에 넣어 아래와 같이 신속하게 무시됩니다 :
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(1));
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
웹 서비스가 HTTP GET과 호환되지 않습니다. 맞습니까? 또는 어떻게해야합니까?
감사합니다.
덕분에, 내가해야 나는 행운을 빌어 WebMethod에서 CacheDuration을 시도했다고 덧붙였다. – kevin
HttpContext.Current.Response.End(); 돌아 오기 전에 방법의 끝에서? –