views:

366

answers:

1

Hi guys, I have a Webview that must load an image! When I upload this image I see every time the same image as before, and i must reboot my app to see the new image... I think is a cache problem..How can I solve that??

+2  A: 

One quick and easy method would be to append the current time stamp onto the url whenever you load it.

So instead of loading:

http://www.myhost.com/myimg.jpg

you'd load

http://www.myhost.com/myimg.jpg?12345689

Using a cache breaker like this is a very common method in web development to force reloading of content.

I did do some quick googling and it appears clearing out NSURL's cache won't do the trick. In 10.6 the api reloadFromOrigin: may do the trick, but I'm not aware if this has made it's way onto the iphone yet.

Edit:

I found this page in the docs. It looks like you can use the preferences system to say whether or not to use caching. Not tested, but that'd be something to look at.

Bryan McLemore