nsurlcache

Transition from RestKit to pure AFNetworking 2.0

北城以北 提交于 2019-12-02 20:24:41
I'd been using RestKit for the last two years, but recently I've started thinking about transition from these monolith framework as it seems to be really overkill. Here's my pros for moving forward: There is big need in using NSURLSession for background fetches and RestKit has only experimental branch for transition to AFNetworking 2.0. No actual dates when transition will be finished. (Main Reason) No need for CoreData support in network library as no need for fully functional offline data storage. Having headache with new concept of response/request descriptors as they don't support

How to disable the URLCache completely with Alamofire

被刻印的时光 ゝ 提交于 2019-12-02 05:15:05
问题 Using Xcode 7.3 iOS 9.2 all in Swift none of that horrible Objective C I have been working on this for a while and been around the block three times now. I have tried this post here and it didn't work http://www.mzan.com/article/32199494-alamofire-how-remove-cache.shtml I have also try to use apple documentation but that is so crappy I cannot make sense of if. So what I am doing is making two Alamofire calls to my server. One to test the credentials of the login information to see if the

How to disable the URLCache completely with Alamofire

六月ゝ 毕业季﹏ 提交于 2019-12-02 02:02:33
Using Xcode 7.3 iOS 9.2 all in Swift none of that horrible Objective C I have been working on this for a while and been around the block three times now. I have tried this post here and it didn't work http://www.mzan.com/article/32199494-alamofire-how-remove-cache.shtml I have also try to use apple documentation but that is so crappy I cannot make sense of if. So what I am doing is making two Alamofire calls to my server. One to test the credentials of the login information to see if the input is right. The second is to download and return the customer information for there viewing. Both are

Mutable NSHTTPURLResponse or NSURLResponse

99封情书 提交于 2019-12-01 09:17:19
I need to modify response headers in an NSURLResponse. Is this possible? Colin Barrett I was just talking about this with a friend. My suggestion would be to write a subclass of NSURLResponse. Something along these lines: @interface MyHTTPURLResponse : NSURLResponse { NSDictionary *myDict; } - (void)setAllHeaderFields:(NSDictionary *)dictionary; @end @implementation MyHTTPURLResponse - (NSDictionary *)allHeaderFields { return myDict ?: [super allHeaderFields]; } - (void)setAllHeaderFields:(NSDictionary *)dict { if (myDict != dict) { [myDict release]; myDict = [dict retain]; } } @end If you're

How do I invalidate iOS's cache for a particular URL?

喜欢而已 提交于 2019-11-30 20:29:17
Using NSURLSession 's default caching, how do I invalidate the cache for a particular URL? I note NSURLCache 's removeCachedResponseForRequest: method, but that takes an NSURLRequest object, which I don't have for the original request. Do I need to store those as I create them so I can then pass them back into removeCachedResponseForRequest: or can I just create a new one with the appropriate URL which will then serve as equivalent for the purpose, even if it doesn't have the same header fields and other properties as the original? If you want to go further you could reset the cached response

On iOS where is the NSURLCache cache stored if diskPath:nil?

和自甴很熟 提交于 2019-11-30 12:25:56
I've come across code that looks like this: NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil]; The problem is that I haven't been able to find what's the expected behavior when diskPath is passed nil. NSURLCache docs don't explicitly describe this situation nor I have been able to figure it out with my own testing. Where is the cache stored? or is that code above a bug? Thanks. I had some free time today to do some testing and found the answer. Nothing exciting but if you are curious: By default iOS will use a database

NSURLConnection on iOS doesn't try to cache objects larger than 50KB

孤人 提交于 2019-11-30 07:30:17
问题 Despite Apple's documentation indicating otherwise, NSURLCache on iOS doesn't do any disk (flash) caching at all. You can subclass NSURLCache to change the behaviour of the fetch and store operations to use the disk (like SDURLCache does), but due to the following severe limitations of how the cache is used and implemented, this doesn't work as well as you'd expect: NSURLConnection doesn't even call storeCachedResponse:forRequest: for files over about 50KB (>= 52428 bytes, to be exact). This

How do I invalidate iOS's cache for a particular URL?

此生再无相见时 提交于 2019-11-30 05:32:42
问题 Using NSURLSession 's default caching, how do I invalidate the cache for a particular URL? I note NSURLCache 's removeCachedResponseForRequest: method, but that takes an NSURLRequest object, which I don't have for the original request. Do I need to store those as I create them so I can then pass them back into removeCachedResponseForRequest: or can I just create a new one with the appropriate URL which will then serve as equivalent for the purpose, even if it doesn't have the same header

When exactly do things get removed from urlcache's memory and disk?

半世苍凉 提交于 2019-11-29 11:47:31
let memoryCapacity = 200 * 1024 * 1024 let diskCapacity = 1 * 1024 * 1024 let cache = URLCache(memoryCapacity: memoryCapacity, diskCapacity: diskCapacity, diskPath: "myDataPath") URLCache.shared = cache Scenario1 I'm setting urlcache's memory to 200mb and setting the disk space to 1mb. Then I download an image. Turn off internet and force quit the app, launch the app again by tapping it, and trigger a call (to download image) but it immediately crashes because data is nil Needless to say if I turn off internet, it will still read from cache as expected and no crash would happen. Scenario2 If I

NSURLConnection on iOS doesn't try to cache objects larger than 50KB

爱⌒轻易说出口 提交于 2019-11-29 04:10:23
Despite Apple's documentation indicating otherwise , NSURLCache on iOS doesn't do any disk (flash) caching at all. You can subclass NSURLCache to change the behaviour of the fetch and store operations to use the disk (like SDURLCache does), but due to the following severe limitations of how the cache is used and implemented, this doesn't work as well as you'd expect: NSURLConnection doesn't even call storeCachedResponse:forRequest: for files over about 50KB (>= 52428 bytes, to be exact). This makes subclassing NSURLCache pointless for our use (200KB images), because it won't even get to the