NSURLCache Joke / iPhone

Did you ever wonder why Apple’s own Demo App URLCache doesn’t use the NSURLCache class, but rather reimplements disk caching instead? Well, it looks like NSURLCache promises disk-caching, but doesn’t keep this promise.

flattr this!

Comments 5

  1. Paul Lancefield wrote:

    Yep that’s true. The iPhone uses an in memory cache – which is kinda limited and won’t store to “disk” (flash memory). But UIWebView still checks the cache for these pages that can’t be stored. But this behaviour is good because

    1) In memory caching is better than nothing.

    2) You can override the shared cache class to change the behaviours and you could implement your own caching scheme if you really want to and it will then be used by UIWebView.

    3) at any time in the future if the “disk” cache is enabled, UIWebView will get the benefit. So for example, on the iPad you may find “disk” caching enabled by default (I don’t know I haven’t checked – but it’s an example) in which case your iPhone apps will benefit from it when running on the iPad.

    Posted 08 Feb 2010 at 1:40 pm
  2. Olivier Poitrey wrote:

    I’ve created a lib aimed at giving on-disk caching support back in NSURLCache. You can find it at http://github.com/rs/SDURLCache

    Still, I can’t understand why this support have been removed for this platform at the first place. Wouldn’t have been better from Apple to just set disk cache capacity to 0 by default and let developers to decide if he needs it or not?

    Posted 17 Mrz 2010 at 11:15 am
  3. mro wrote:

    Nice work, Olivier! Full ACK, I don’t understand that either.

    Posted 18 Mrz 2010 at 9:48 pm
  4. somebody wrote:

    > Still, I can’t understand why this support have been removed for this platform….

    maybe because they want to save flash memory life resource?..

    Posted 26 Sep 2010 at 4:33 pm
  5. Marcus Rohrmoser wrote:

    Ha,
    finally Apple seems to have fixed it in iOS 5: http://petersteinberger.com/blog/2012/nsurlcache-uses-a-disk-cache-as-of-ios5/

    (didn’t verify myself though)

    Posted 28 Mrz 2013 at 12:08 pm

Trackbacks & Pingbacks 2

  1. From A Webapp By Another Name II – The many pitfalls of using the application cache on mobile platforms | Chris's Excellent Adventure In JavaScript on 10 Jun 2011 at 6:36 pm

    [...] iOS in such a way that it will fail silently. This has been widely reported e.g. here, here and here. Obviously without disk caching of the resources, as soon as your app is closed (or at any time [...]

  2. From Scott Logic » A Webapp By Another Name II – The many pitfalls of using the application cache on mobile platforms on 23 Sep 2011 at 10:43 am

    [...] iOS in such a way that it will fail silently. This has been widely reported e.g. here, here and here. Obviously without disk caching of the resources, as soon as your app is closed (or at any time [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *