Search code examples
cachingthree20photottphotoviewcontroller

three20 TTPhotoViewController to not cache the images


I am using TTPhotoViewController to show photo coming from remote repository. If I change the content of the photo on remote repository but still use the same url, on my iPhone client, the original phone will still be shown when load up the TTPhotoViewController. So the image is somehow cached, is there way to not do that?

I also noticed the same problem with one of the TTTableStyledTextItem that have url to an image.

So is there anyway to clear cache or auto refresh if the target image is changed?


Solution

  • Three20 uses an internal cache called TTURLCache that supports all kinds of caches including ETag and such. Manually disable cache to disk via:

    [TTURLCache sharedCache].disableDiskCache = YES;

    I wouldn't recommend disabling the cache and instead you should look at your http cache header on your images - Three20 by default is respecting it. One way I do recommend you to handle it is adding a dummy parameter to your image urls (assuming you get the image url through some kind of an api). then simply append a dummy version number to it. Each time the version chages your app will get a new version of the image. instead of:

    http://yoururl.com/image.png

    use

    http://yoururl.com/image.png?dummyversion=232