I'm having a small problem with request caching using NSURLConnection asynchronous connections on the iPhone. I don't know if I understood something incorrectly, or if Cocoa is doing the opposite to what it's supposed to do...
The documentation for NSURLRequest says that:
NSURLRequestReloadIgnoringLocalCacheData
Specifies that the data for the URL load should be loaded from the originating source. No existing cache data should be used to satisfy a URL load request.
and:
NSURLRequestReloadIgnoringLocalAndRemoteCacheData
Specifies that not only should the local cache data be ignored, but that proxies and other intermediates should be instructed to disregard their caches so far as the protocol allows.
Now, if I send an NSURLRequest with NSURLRequestReloadIgnoringLocalCacheData (which is supposed to ignore local cache, but use remote cache if available), the headers that are sent are:
GET /dashboard HTTP/1.1 User-Agent: XBlip1.0 CFNetwork/422.15.2 Darwin/9.6.0 (i386) (iMac8%2C1) X-Blip-Api: 0.02 Accept: application/json Authorization: Basic (...) Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: keep-alive Host: api.blip.pl
And the status is 200 OK. But if I use NSURLRequestReloadIgnoringLocalAndRemoteCacheData, which is supposed to ignore both local and remote caches, as the name suggests, one additional header is added:
If-None-Match: "d751713988987e9331980363e24189ce"
And the response is 304 Not Modified. I've checked the HTTP RFC, and for "If-None-Match" it says that:
If any of the entity tags match the entity tag of the entity that would have been returned in the response to a similar GET request (without the If-None-Match header) on that resource, (...) then the server MUST NOT perform the requested method (...) Instead, if the request method was GET or HEAD, the server SHOULD respond with a 304 (Not Modified) response
So it seems that if I use NSURLRequestReloadIgnoringLocalAndRemoteCacheData, instead of ignoring the remote cache, Cocoa tells the remote server explicitly that it should use remote cache, and if I use NSURLRequestReloadIgnoringLocalCacheData, it doesn't add that line and in effect the remote cache is not used.
So what exactly is happening here? Did I miss something, or is Cocoa setting a wrong header?