How to choose TTURLRequestCachePolicy?
I'm building an app with Three20 and I'm using the photo gallery component.
I can't find any documentation about the different cache policy available.
Could you explain to me each 开发者_开发知识库of them ?
TTURLRequestCachePolicyDefault
TTURLRequestCachePolicyDisk
TTURLRequestCachePolicyEtag
TTURLRequestCachePolicyLocal
TTURLRequestCachePolicyMemory
TTURLRequestCachePolicyNetwork
TTURLRequestCachePolicyNoCache
TTURLRequestCachePolicyNone
Thanks !
I'm not sure of the exact policy of each type, and they are not well documented. These is the information I have found out by using and reading the code:
TTURLRequestCachePolicyNone
- requests will not use three20 cache system. meaning each request will perform a network request.
TTURLRequestCachePolicyMemory
- the request will try to look for an existing cache object in the device memory. memory is cleaned each time the application is terminated. not sure how useful it is. from what i have seem, it's working only for UIImage objects
TTURLRequestCachePolicyDisk
- Three20 saves cache objects in the application document folder as files. The request will look only on that disk cache.
TTURLRequestCachePolicyNetwork
- not sure. i think it's checks the header expire date of the content.
TTURLRequestCachePolicyNoCache
- will not cache new responses and will not look for cache objects in existing cache
TTURLRequestCachePolicyEtag
- requests will be looked based on their header etag. I think it's a little buggy in three20, so it's better not to use it.
TTURLRequestCachePolicyLocal
- requests will be looked on both disk & memory cache
TTURLRequestCachePolicyDefault
- requests will be looked in all cache types (besides the etag)
From my experience, i use TTURLRequestCachePolicyDefault
with expiration time i want, and TTURLRequestCachePolicyNoCache
for requests i want to disable cache and make sure each request is doing a network call.
精彩评论