Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Image caching in Tableviewrow?

Hi!
I have a tableview with an image in each row. These images are retrieved from a server. However, they don't seem to be cached: If I scroll down, and back up, the images on top, that have been loaded before, have to be requested from the server again. This is quite slow (as the server connection takes some time).
In another app, this seems to be handled better, while the code is similar.
How does Titanium determine to cache an image?

— asked June 29th 2010 by Martijn Pannevis
  • cache
  • image
  • iphone
  • server
  • tablerow
  • tableview
0 Comments

7 Answers

  • I've solved this issue before and published up a git repo for general use. You can find it on my blog here and on Github here

    — answered March 18th 2011 by Kevin Hopkins
    permalink
    1 Comment
    • That looks great!

      — commented February 16th 2012 by Esben Maaløe
  • I recommend to switch to the latest current build of the upcoming version 1.6. We had similar problems but in the current version the caching is fixed! Image caching comes automatically. If you use class names for similar rows the scroll experience with remote images is very good. They did a lot a this. Unfortunately row classing is not stable enough (on android).

    — answered January 27th 2011 by Sven Wiese-Solty
    permalink
    1 Comment
    • Is it confirmed that caching is fixed as of 1.6?

      — commented March 18th 2011 by Joe iEntry
  • Are you sure the images get requested again after scrolling down and up again?

    They certainly never used to.

    — answered June 29th 2010 by Kosso
    permalink
    0 Comments
  • Well, I'm not 100% sure they do get requested again, although it does feel that way. They do dissapear and take a while to return tho. I'll test with a proxy at some point if they do get requested again.
    I do know this isn't how it used to behave, but I didn't actively change anything. Maybe the image size is a factor? Maybe the way it's hosted? (headers, etc?)

    — answered June 29th 2010 by Martijn Pannevis
    permalink
    0 Comments
  • It seems my hunch about headers was right: the images on this new listing have a no-cache header, which seems to prevent Titanium from caching them, even for a few seconds.
    I'm guessing I can change this in the titanium source, or ask if the server can be changed (which will be hard).

    — answered June 29th 2010 by Martijn Pannevis
    permalink
    3 Comments
    • I guess you could create your own cache and save the files locally - adding a timeout/lifespan to them too?

      — commented June 30th 2010 by Kosso
    • Hmm, no such luck yet. I tried commenting out both cacheable = NO in queueRequestDidFinish in imageLoader.m. I expected this to work, but it doesn't . cachable is set to YES, but the image still isn't cached. Any pointers are welcome.

      — commented June 30th 2010 by Martijn Pannevis
    • I'm currently suspecting it having to do with the images being redirected via a 302 redirect. While this means the client should check later if the content has changed, 5 seconds later seems a bit fast…

      — commented June 30th 2010 by Martijn Pannevis
  • we're experiencing this exact same issue….did you ever come up with a resolution?

    Thanks

    ~Brian

    — answered January 26th 2011 by Brian Dittmer
    permalink
    0 Comments
  • Sven…

    thanks for the heads up. We'll check it out once 1.6 is available. Android is our primary target platform….iPhone secondary.

    ~Brian

    — answered January 27th 2011 by Brian Dittmer
    permalink
    1 Comment
    • We just updated to mobile 1.6 RC1 – and we aren't seeing any improvement for image caching on Android. Tablerowview images still disappear when rows scroll off the screen..and the images take time to reappear once those rows are re-displayed.

      We are using classnames - though ALL rows are formatted with exactly the same data.

      Wondering if anyone has seen any Android image caching improvements with 1.6 & if you needed to do anything in particular to take advantage of said improvements?

      Thanks
      ~Brian

      — commented February 14th 2011 by Brian Dittmer
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.