0
如何使用各種緩存策略(NSURLRequestCachePolicy)提高下載性能?下載應用程序示例中使用哪種最佳解決方案?各種NSURLRequest CachePolicies的差異?
如何使用各種緩存策略(NSURLRequestCachePolicy)提高下載性能?下載應用程序示例中使用哪種最佳解決方案?各種NSURLRequest CachePolicies的差異?
Apple put forward a neat document for the reference
它說
NSURLRequestUseProtocolCachePolicy
Specifies that the caching logic defined in the protocol implementation, if any, is used for a particular URL load request. This is the default policy for URL load requests.
Available in OS X v10.2 and later.
Declared in NSURLRequest.h.
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.
Available in OS X v10.5 and later.
Declared in NSURLRequest.h.
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.
Available in OS X v10.5 and later.
Declared in NSURLRequest.h.
NSURLRequestReloadIgnoringCacheData
Replaced by NSURLRequestReloadIgnoringLocalCacheData.
Available in OS X v10.2 and later.
Declared in NSURLRequest.h.
NSURLRequestReturnCacheDataElseLoad
Specifies that the existing cached data should be used to satisfy the request, regardless of its age or expiration date. If there is no existing data in the cache corresponding the request, the data is loaded from the originating source.
Available in OS X v10.2 and later.
Declared in NSURLRequest.h.
NSURLRequestReturnCacheDataDontLoad
Specifies that the existing cache data should be used to satisfy a request, regardless of its age or expiration date. If there is no existing data in the cache corresponding to a URL load request, no attempt is made to load the data from the originating source, and the load is considered to have failed. This constant specifies a behavior that is similar to an 「offline」 mode.
Available in OS X v10.2 and later.
Declared in NSURLRequest.h.
NSURLRequestReloadRevalidatingCacheData
Specifies that the existing cache data may be used provided the origin source confirms its validity, otherwise the URL is loaded from the origin source.
Available in OS X v10.5 and later.
Declared in NSURLRequest.h.
Declared In
NSURLRequest.h
感謝您的詳細信息。 – sams58
值得一提的是,其中一些在當前的iOS上完全沒有實現(在撰寫本文時爲6)。 – Leonardo