I am using NSURLCache
with AFNetworking
. Caching works fine but there is no way to check if a response was actually retrieved from cache.
To check if a cached version is available, I use
[[NSURLCache sharedURLCache] cachedResponseForRequest:_request];
to check for a cached version of my file.
My server is sending the following headers:
Cache-Control:public, must-revalidate, max-age=0
ETag:"317a405bf9f69346c1f0438736a3d02e"
This should basically make sure that the cached response is stale immediately after download.
However, cachedResponseForRequest:
still loads the previously cached version on disk, even if it actually is expired.
- Does
NSURLCache
never expire or am I not sending the correct headers, etc? - Am I missing something else here?
EDIT
I have also tried to send
Expires: "Mon, 27 May 2013 14:34:50 GMT"
header and the response is still returned from the cache, even if it already expired.
I get the feeling that NSURLCache
is not working correctly...