ios - NSURLCacheStoragePolicy request vs response -


There is little confusion in understanding the caching mechanism in the iOS. I

I want to customize my caching policy I am reading this blog. I want my caching to be completely controlled by my server caching header

so I set

  [request set policy: NSURLRequestReturnCacheDataElseLoad];  

The above mentioned blog now specifies that I can also specify a cash policy for NSCachedURLResponse. (NSCachedURLResponse *) Connection: (NSURLConnection *) connection will be CacheResponse: (NSCachedURLResponse *) Cached Response {NSMutableDictionary * mutableUserInfo = [[Cached Response User Infoda] MuteCopy]; NSMutableData * mutableData = [[Cached Response Data] MuteCopy]; NSURLCacheStoragePolicy storagePolicy = NSURLCacheStorageAllowedInMemoryOnly; // ... return [[NSCachedURLResponse alloc] initWithResponse: [Cached Response Response] Data: Migration Data User Information: mutableUserInfo storage policy: storage policy]; }

Then what is the meaning of having a cash policy for the first time? Storage policy is a request parameter or response parameter.

The difference is here:
NSURLRequestCachePolicy is client-server data management The feature that loads sources of data (that is, local cache or remote server ) and describes situations between them

NSURLCacheStoragePolicy is the only client data management utility that describes storage for local cache (memory, local database and etc; only memory; none). TI.

For example, if you use the NSURLRequestReturnCacheDataElseLoad for the request and for response NSURLCacheStorageAllowedInMemoryOnly is such a scenario:

  1. You initiate the request;
  2. The NSURL loads the connection connection to the server because it requests the first time and there is no cache;
  3. When the response is received, it is saved in cash storage on the cash memory (this will be live only when your application is launched;
  4. ;
  5. Loads the NSRR connection connection from local cache storage;
  6. You close the application (cache storage has been released), launch it again and launch a Only start the request;
  7. NSURLConnection of the load data from the server The form was released cache storage based on memory.

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -