The difference is here:
NSURLRequestCachePolicy
is client-server data management feature that describes sources of data that should be loaded (local cache or remote server) and conditions between them.
NSURLCacheStoragePolicy
is only client data management feature that describes storage for local cache (memory, local database and etc; only memory; none).
For example if you use NSURLRequestReturnCacheDataElseLoad
for request and NSURLCacheStorageAllowedInMemoryOnly
for response then such scenario takes place:
- You initiate request;
- NSURLConnection loads data from server as it first request and there are no any cache;
- When response is received it saved to cache storage that based on memory (it will live only while your application is launched;
- You initiate the same request on more time;
- NSURLConnection loads data from local cache storage;
- You close application (cache storage is released), launch it again and initiate the same request;
- NSURLConnection loads data from server as cache storage based on memory was released.