开发者

Sync or cache data from a web app with an iphone app

I have a web application already in place, and I'm working on an 开发者_StackOverflow中文版iPhone app. I have a fundamental question about caching/syncing data between the two.

So probably 80% of the iPhone app is more-or-less reading (GETing) data from the webapp (it's heavy on stats, so it gives you access to your stats and such). Should I be reloading this data every time a screen is loaded? If so, no syncing/caching would be required, since it would be "fresh" every time. However, it seems like I'd be sending unnecessary requests back to the web server for no reason in most cases, since often the data would not have changed.

I was thinking of caching this data locally on the phone somehow, but I don't know what the "best practices" are for this. Or if I should just sync up a sqlite DB on the iPhone with data from the web app, and provide "refresh" buttons in the nav controller title bar to manually request an update.

I'm not necessarily looking for code, just more-or-less putting a plan together.

Suggestions? Thanks!


It really just depends on how often the data on your web server will be updated. If it's updated infrequently, then I would suggest caching the data on the iPhone. But if there is a flurry of activity on your web server and having access to the most up to date information is considered critical to the success of your project, then you'll need to send GET requests.

I don't know if the iPhone can utilize Comet, but that could be an option to "push" updates to your phone if it's supported.

You could also have the phone periodically check the server for updates. The server could return status code 304 Not Modified if the data hasn't changed. This is less data intensive than pulling the actual data in each GET request. In this case, you would only pull fresh data if 304 was not returned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜