Skip to content

cache-control not read #8

Closed
dqueffeulouatw opened this Issue Jul 11, 2011 · 1 comment

2 participants

@dqueffeulouatw

It seems like sometimes the cache-control: max-age in the response is not read.
Actually, I found maybe an explanation for that in the AFURLCache :

- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse forRequest:(NSURLRequest *)request

    [...]

        AFCacheableItem *item = [[AFCacheableItem alloc] initWithURL:oURL lastModified:lastModified expireDate:expireDate contentType:contentTypeHeader];
        // MUST BE DONE ??
        [item handleResponse:cachedResponse.response];
        //
        [[AFCache sharedInstance] importCacheableItem:item withData:cachedResponse.data];   
        [item release];
    }               
}

the handleResponse: is not called (I added myself), so all the stuff made on headers is not done, only those passed as parameters.
Is it safe to call handleResponse: here ?

@artifacts
Owner

Don't use AFURLCache anymore:

http://stackoverflow.com/questions/7166422/nsurlconnection-on-ios-doesnt-try-to-cache-objects-larger-than-50kb

Instead, register AFHTTPURLProtocol for http requests, so they'll be routed through AFCache:

[NSURLProtocol registerClass:[AFHTTPURLProtocol class]];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]];
[self.webView loadRequest:request];
@artifacts artifacts closed this Sep 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.