views:

109

answers:

1

When I built my first handful of Twitter applications, I wrote code to cache user icons locally. At the time, it just didn't seem like a good idea to assume that these icons would always be available at their original locations. These were relatively low-traffic sites though, and even though I was grabbing the user icons on login, it didn't impact performance much. Neither did serving those user icons back to my visitors.

Now, however, I'm working on an application that has significantly more traffic and I'm wondering whether or not I can get away with just hotlinking the icons at the URLs that the Twitter API returns. It doesn't seem like a great idea, but most (all?) of the Twitter app code that I've looked at just hotlink the profile images. Maybe that's because they were mostly based on the same python-twitter auth tutorial or maybe it's because their authors know something I don't.

If it is a good idea to just hotlink the icons, what happens when a user uploads a new icon to Twitter and decides to never sign in to my app ever again. Does Twitter purge their old icon that I'm conveniently hotlinking at some point? Ultimately, it's not an insurmountable problem, but it'd be good to know one way or the other.

Any help you can send my way is appreciated.

+1  A: 

I believe it is fair game to hotlink the url. It is after all, included in every place where user information is returned, indicating that it is a highly volatile resource.

I don't believe you would be against any terms or agreements by hotlinking to that API.

If your application is a web-based application, then I would just hotlink it.

However, if it is not a web-based application and you are finding that performance is suffering from hotlinking, I would keep a list of urls of profile images mapped to user ids and then download the image and store it if you don't have it.

Then, every time you get user information, check the url, if it is different from what you have, download the content again and display that (updating your map of course as well).

On a somewhat related note, remember that the public timeline is cached for 60 seconds, so if you are getting your information from there, you shouldn't be doing a a frequency higher than that.

casperOne

related questions