nsurlcache

NSURLCache doesn't cache

流过昼夜 提交于 2020-03-03 04:39:14
问题 I'm using Xcode 6.1 (6A1030), both iOS7 & iOS8 Simulators. NSURLCache does not seem to cache anything. I use the "Cache-Control" header. My server returns the Cache-Control header with 'max-age=6000'. In this example, I tamper a request from Google, which is also not cached: AppDelegate: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { var URLCache = NSURLCache(memoryCapacity: 500 * 1024 * 1024, diskCapacity: 500 *

NSURLCache doesn't cache

喜夏-厌秋 提交于 2020-03-03 04:38:25
问题 I'm using Xcode 6.1 (6A1030), both iOS7 & iOS8 Simulators. NSURLCache does not seem to cache anything. I use the "Cache-Control" header. My server returns the Cache-Control header with 'max-age=6000'. In this example, I tamper a request from Google, which is also not cached: AppDelegate: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { var URLCache = NSURLCache(memoryCapacity: 500 * 1024 * 1024, diskCapacity: 500 *

URL filtering for UIWebView on the iPhone

限于喜欢 提交于 2020-01-24 19:45:46
问题 Can someone please shed some light on how I would get this to work: http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/ I tried making the "FilteredWebCache.h" and "FilteredWebCache.m" files in my project, but it said that "FilterManager.h" did not exist. What am I meant to do with those files? This I put in viewDidLoad: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docDir = [paths objectAtIndex:0];

NSURLCache, together with NSURLSession, does not respect: Cache-Control: max-age:86000, private, must-revalidate

蓝咒 提交于 2020-01-24 10:17:05
问题 In AppDelegate.m, I configured: NSURLCache *sharedURLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 diskCapacity:100 * 1024 * 1024 diskPath:@"FhtHttpCacheDir"]; Then the http request: - (void) testRestfulAPI{ NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:config]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http:/

Overriding NSURLCache's cachedResponseForRequest to cache UIWebView assets with Three20

纵饮孤独 提交于 2020-01-15 09:08:23
问题 I need to cache a web-sourced image (i.e. not bundle sourced) that is going into a webview. Normally I'd just request the image and convert it into base-64 and stick it in the HTML, but if I have 100 images in line I can't quite do that. So I searched around a bit and found a way to grab the image request by subclassing NSURLCache and overriding cachedResponseForRequest . My code is below. I'm able to do the request just fine, I can get the data back and print it out, I made a UIImage from

Pre-cache Images for AFNetworking's UIImageView category

僤鯓⒐⒋嵵緔 提交于 2020-01-13 08:43:09
问题 When my app loads, I pull down a JSON representation of 99 objects. Each object has an 'image_url' field, which I pass to AFNetworking's setImageWithURLRequest . My images load in a tableView, and consequently, only the first several cells make requests for their images. It's not until I scroll down that subsequent image requests are made. Once I pull down the initial dataset, I'd like to be able to kick off a background process that goes out and downloads the 95 or so objects that aren't

How to set iOS cache and disk storage size and how does cache get restored from disk storage after app termination?

筅森魡賤 提交于 2020-01-01 05:07:05
问题 I've already asked When exactly do things get removed from urlcache's memory and disk? Now I have some more follow up questions: The memory cache is restricted by the iPhone's ram (usually 2Gb). But the disk Persistence is limited by 64Gb or 128Gb. Is that correct? Does it ever make sense to have a persistence more than your memory storage. Can it be useful if you don't want to have a high memory footprint (and don't want app to get terminated from its suspended state) ie allow the cache to

NSCachedURLResponse returns object, but UIWebView does not interprets content

夙愿已清 提交于 2019-12-30 17:35:20
问题 I am sending a request to a UIWebView. There are AJAX-calls on the loaded webpage. I need to analyze the AJAX-traffic in order to determinate, if the user is logged in or not. For doing this I installed a NSURLCache in the AppDelegate: MYURLCache *cache = [[MYURLCache alloc] init]; [NSURLCache setSharedURLCache:cache]; This MYURLCache-class correctly receives the traffic that runs through the webview. I can terminate the AJAX-calls only. I then spawn an own request of the AJAX-calls. This one

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

核能气质少年 提交于 2019-12-29 07:52:25
问题 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

How to use NSURLSession to determine if resource has changed?

只愿长相守 提交于 2019-12-28 13:58:13
问题 I'm using NSURLSession to request a JSON resource from an HTTP server. The server uses Cache-Control to limit the time the resource is cached on clients. This works great, but I'd also like to cache a deserialized JSON object in memory as it is accessed quite often, while continuing to leverage the HTTP caching mechanisms built into NSURLSession. I'm thinking I can save a few HTTP response headers: Content-MD5 , Etag , and Last-Modified along with the deserialized JSON object (I'm using those