2013-12-10 4 views
0
내가 ASIHTTPRequest cache에 대한 응답 데이터를 많이 시도하고

, 내가 설명서를 읽고 많은 솔루션을 시도했지만 운 :(ASIHTTPRequest 캐시 응답 데이터

이 내 코드입니다 않은 :

_request = [[ASIFormDataRequest alloc]initWithURL:[NSURL URLWithString:NSLocalizedString(@"kBaseUrl", nil)]]; 
_request.delegate = self; 
[_request setDownloadCache:[ASIDownloadCache sharedCache]]; 
[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO]; 
[_request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];//ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy 
[_request setSecondsToCache:60*60*24*2]; // Cache for 2 days 
[_request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy]; 
[_request setDefaultResponseEncoding:NSUTF8StringEncoding]; 
[_request setDidFinishSelector:@selector(doneLoadingBody:)]; 
[_request setDidFailSelector:@selector(failedLoadingBody:)]; 
[_request setRequestMethod:@"POST"]; 
[_request setShouldContinueWhenAppEntersBackground:YES]; 
[_request setPostValue:@"someValue" forKey:@"name"]; 
[_request setPostValue:@"someValue" forKey:@"key"]; 
[_request setPostValue:@"someValue" forKey:@"key"]; 
[_request startAsynchronous]; 

if ([_request didUseCachedResponse] == NO) { 

    NSLog(@"Did not Cache Body"); 

} 
+1

정지 ASIHTTPRequest을 사용하고 AFNetworking를 사용하여 시작합니다. ASI는 현재 몇 년 동안 지원되지 않습니다 (ARC 지원이 있다고 생각하지 않습니다). – Eimantas

+0

@Eimantas AFNetworking으로 옮길 계획이지만 현재 시간이 아닙니다. ASIHTTPRequest가있는 기존 프로젝트에서 작업 중이므로 AFNetworking으로 이동하기 전에 시간이 필요합니다. – Atrash

답변

0

당신은 ASIFormDataRequest를 사용하고 기본적으로 POST 작업입니다.

POST는 멱등 방식이 아니므로, 내가 그것을 캐시 의심.

아마도 캐시 메커니즘을 GET 요청으로 테스트를 시작해야 할 것입니다.

일부 참조 : Is it possible to cache POST methods in HTTP?