MKNetworkKit Auto Caching
MKNetworkKit 網上已有不少介紹它的文章了,不過對於它提供的眾多特性的實現機制,還是值得研究研究的。其中 Auto caching 是其中之一。
官方文件是這樣寫的:
High performance background caching (based on HTTP 1.1 caching specs) built in
MKNetworkKit can automatically cache all your “GET” requests. When you make the same request again, MKNetworkKit calls your completion handler with the cached version of the response (if it’s available) almost immediately. It also makes a call to the remote server again. After the server data is fetched, your completion handler is called again with the new response data. This means, you don’t have to handle caching manually on your side. All you need to do is call one method
[[MKNetworkEngine sharedEngine] useCache];
Optionally, you can override methods in your MKNetworkEngine subclass to customize your cache directory and in-memory cache cost.
- 它是基於
HTTP1.1 協議設計的Cache模式,剛好我們請求的後端服務也是基於這個協議,Cache-Control
用的是 max-age=0, private, must-revalidate , ETag
標記快取
- 如果你啟用了 useCache
,它可以將所有的GET請求進行Cache,它根據請求的 url
來判斷是否是同一個請求,然後呼叫快取資料
- 它在返回快取資料時,同時也向伺服器請求最新資料,如果有最新內容,會返回新的 ETag,然後MK會更新快取中的ETag
- 當 APP
退到後端時,快取資料會持久化到Caches目錄中
- 它生成的快取資料檔案根據 unique Identifier
命名,放在 MKNetworkKitCache 目錄中,生成規則可以檢視 MKNetworkKitOperation uniqueIdentifier
方法。
- 用 MKNetworkEngine emptyCache
例項方法清理快取
原文:http://doruby.com/mknetworkkit/third-libs/plugins/cache/2014/05/28/mknetworkkit-auto-caching/
相關文章
- asp.net core 系列之Response caching 之 Distributed caching(3)ASP.NET
- Android Auto-Building Apps for Auto,Getting Started with AutoAndroidUIAPP
- authentication plugin caching_sha2Plugin
- auto型別型別
- inherit與auto
- Auto CAD
- NopCommerce學習(1) Caching
- 11g新特性--result caching
- android auto-Providing Audio Playback for AutoAndroid
- 關於 MYSQL auto_increment_offset和auto_increment_incrementMySqlREM
- mysql的auto_increment_offset和auto_increment_increment配置MySqlREM
- auto_ptr_ref和auto_ptr的關係 (轉)
- 如何用 HTTP Caching 優化網站HTTP優化網站
- z-index:autoIndex
- macOS Development - Auto LayoutMacdev
- MySQL AUTO_INCREMENTMySqlREM
- Auto關鍵字
- asp.net core 系列之Response caching(1)ASP.NET
- Everyone should be using low level caching in RailsAI
- android auto-Providing Messaging for Auto(UnreadConversation)Android
- redis:auto-completeRedis
- C++ auto變數變數
- 11g auto maintenanceAINaN
- margin:0 auto;不居中
- Linux auto-mountLinux
- C++ 14 auto 教程C++
- MySQL的AUTO_INCREMENTMySqlREM
- Joomla & Toad auto traceOOM
- 掌握了Docker Layer Caching才敢自稱精通DockerfileDocker
- 理解 Nginx HTTP 代理, 負載均衡, Buffering, CachingNginxHTTP負載
- Python進階 函式快取 (Function caching)Python函式快取Function
- [20170621]Session Cursor Caching 2.txtSession
- [20170621]Session Cursor Caching 4.txtSession
- Plan for caching and performance in SharePoint Server 2013ORMServer
- OPTIMIZER_INDEX_CACHING & OPTIMIZER_INDEX_COST_ADJIndex
- [譯] CSS Grid 之列寬自適應:`auto-fill` vs `auto-fit`CSS
- AUTO START ORACLE ON LINUX(zt)OracleLinux
- auto_ptr原始碼分析原始碼