3 ms·
What’s in Your iOS Image Cache?
- stcredzero 16y agoI should also post this to stackoverflow, but I'm wondering if anyone knows if and how inline images are cached in web pages on iOS. I'm interested in particular how a UIWebView would behave with code like: <img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLSyH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPjgAwXEQA7" alt="embedded image"> Is this known to be cached somewhere else on the device? EDIT: I suppose I could use find on the simulator's directories and look for a file with the right MD5 hash.
- saurik 16y agoI am reasonably confident that such an image is "cached" by being part of an HTML document that itself was cached. I mean, the URL for the thing is the content: one would seriously hope that there isn't a URL->data cache somewhere holding that image ;P.
- Someone 16y ago1. The decoded Base64 data is smaller (three quarters of the size?) than the encoded data. 2. Keeping only the encoded data would mean having to decode it every time the image gets redisplayed. Ideally, one would remove the Base64 coded data from the document, and cache the binary data.
- mike-cardwell 16y agoAnd when the page is loaded again, how would the browser know that the base64 encoded data in the page matches the binary data that has been cached?
- stcredzero 16y agoWhatever the behavior is, it's probably in WebKit. I should test this out on Chrome and Safari as a first pass.
- Someone 16y agoGood question. I would guess that it would just decode it again when it reloads the page. That shouldnt happen often, if people set the page's time-to-live correctly. If they don't, you have to reparse the page anyways, as any content could have changed. When redisplaying a page without reloading, the browser should just use the parsed page.
- stcredzero 16y agoI am reasonably confident that such an image is "cached" by being part of an HTML document that itself was cached I'm being sneaky and shoving Javascript into a UIWebView to generate the image. Note that I asked if the image was cached elsewhere.
- saurik 16y agoI figured you were, and I apologize for not using the word "only"?
- egb 16y agoAnybody know the Frank Kim who wrote the article? I tried to contact him to say that his captcha always says "invalid" but he doesn't have any contact info on there that I could find...