NSURLRequestCachePolicy 缓存策略
2015-06-09 19:36
489 查看
NSURLRequestCachePolicy 缓存策略
1> NSURLRequestUseProtocolCachePolicy = 0, 默认的缓存策略,如果缓存不存在,直接从服务端获取。如果缓存存在,会根据response中的Cache-Control字段判断下一步操作,如:Cache-Control字段为must-revalidata,则询问服务端该数据是否有更新,无更新的话直接返回给用户缓存数据,若已更新,则请求服务端.
2> NSURLRequestReloadIgnoringLocalCacheData = 1,忽略本地缓存数据,直接请求服务端.
3> NSURLRequestIgnoringLocalAndRemoteCacheData = 4,忽略本地缓存,代理服务器以及其他中介,直接请求源服务端.
4> NSURLRequestReloadIgnoringCacheData =NSURLRequestReloadIgnoringLocalCacheData
5> NSURLRequestReturnCacheDataElseLoad= 2, 有缓存就使用,不管其有效性(即忽略Cache-Control字段), 无则请求服务端.
6> NSURLRequestReturnCacheDataDontLoad =3, 死活加载本地缓存. 没有就失败.(确定当前无网络时使用)
7>NSURLRequestReloadRevalidatingCacheData =5, 缓存数据必须得得到服务端确认有效才使用(貌似是NSURLRequestUseProtocolCachePolicy中的一种情况)
Tips: URL Loading System默认只支持如下5中协议: 其中只有http://和https://才有缓存策略.
(1) http://
(2) https://
(3) ftp://
(4) file://
(5) data://
转自:http://blog.sina.com.cn/s/blog_914c141d0101p35o.html
1> NSURLRequestUseProtocolCachePolicy = 0, 默认的缓存策略,如果缓存不存在,直接从服务端获取。如果缓存存在,会根据response中的Cache-Control字段判断下一步操作,如:Cache-Control字段为must-revalidata,则询问服务端该数据是否有更新,无更新的话直接返回给用户缓存数据,若已更新,则请求服务端.
2> NSURLRequestReloadIgnoringLocalCacheData = 1,忽略本地缓存数据,直接请求服务端.
3> NSURLRequestIgnoringLocalAndRemoteCacheData = 4,忽略本地缓存,代理服务器以及其他中介,直接请求源服务端.
4> NSURLRequestReloadIgnoringCacheData =NSURLRequestReloadIgnoringLocalCacheData
5> NSURLRequestReturnCacheDataElseLoad= 2, 有缓存就使用,不管其有效性(即忽略Cache-Control字段), 无则请求服务端.
6> NSURLRequestReturnCacheDataDontLoad =3, 死活加载本地缓存. 没有就失败.(确定当前无网络时使用)
7>NSURLRequestReloadRevalidatingCacheData =5, 缓存数据必须得得到服务端确认有效才使用(貌似是NSURLRequestUseProtocolCachePolicy中的一种情况)
Tips: URL Loading System默认只支持如下5中协议: 其中只有http://和https://才有缓存策略.
(1) http://
(2) https://
(3) ftp://
(4) file://
(5) data://
转自:http://blog.sina.com.cn/s/blog_914c141d0101p35o.html
/*! @enum NSURLRequestCachePolicy @discussion The NSURLRequestCachePolicy enum defines constants that can be used to specify the type of interactions that take place with the caching system when the URL loading system processes a request. Specifically, these constants cover interactions that have to do with whether already-existing cache data is returned to satisfy a URL load request. @constant 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. @constant NSURLRequestReloadIgnoringLocalCacheData Specifies that the data for the URL load should be loaded from the origin source. No existing local cache data, regardless of its freshness or validity, should be used to satisfy a URL load request. @constant 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. Unimplemented. @constant NSURLRequestReloadIgnoringCacheData Older name for NSURLRequestReloadIgnoringLocalCacheData. @constant NSURLRequestReturnCacheDataElseLoad Specifies that the existing cache data should be used to satisfy a URL load request, regardless of its age or expiration date. However, if there is no existing data in the cache corresponding to a URL load request, the URL is loaded from the origin source. @constant NSURLRequestReturnCacheDataDontLoad Specifies that the existing cache data should be used to satisfy a URL load request, regardless of its age or expiration date. However, if there is no existing data in the cache corresponding to a URL load request, no attempt is made to load the URL from the origin source, and the load is considered to have failed. This constant specifies a behavior that is similar to an "offline" mode. @constant 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. Unimplemented. */ typedef NS_ENUM(NSUInteger, NSURLRequestCachePolicy) { NSURLRequestUseProtocolCachePolicy = 0, NSURLRequestReloadIgnoringLocalCacheData = 1, NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, // Unimplemented NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData, NSURLRequestReturnCacheDataElseLoad = 2, NSURLRequestReturnCacheDataDontLoad = 3, NSURLRequestReloadRevalidatingCacheData = 5, // Unimplemented };
相关文章推荐
- apue.h: No such file or directory
- android&Bluetooth
- easyui textarea IE8中无法换行
- PyQt + QML 快速开发GUI入门总结
- UIDynamics -- 力学部分
- SPH fluid simulation methods & source codes (cpu & gpu)
- 类似微信的ChattingUi
- N-Queens(N皇后问题) --Java版
- UITableView创建样式
- Distinct Subsequences leetcode 115
- Subsequence - HDU 3530 单调队列优化
- 关于UIImagePickerController的理解 (区别于上文的AVCapture)
- 关于ExecuteNonQuery()执行成功却返回-1的问题
- iOS中UIActionSheet的使用
- PHP array_count_values()
- UI设计: UI设计的15项黄金法则
- [android][studio] build a project
- Werther Quest 笔记
- IOS 将RGB颜色值转换为UIColor
- Building,Packaging,Deploying,and Administering Applications and Types