I have data in a backend server that is updated every minute. I'm writing a client that will fetch this data periodically via AJAX, and am wondering how often the client should request new data.
Common sense says a minute, but in the case when a client initially connects 10 seconds before a data refresh, it is left looking at st开发者_高级运维ale data for 50 seconds. My gut tells me that I should refresh every 30 seconds because if a train comes every 10 minutes, the average wait time is 5 minutes. It feels related to me, but could very well not be.
I realize going less than the update period will put more stress on the backend, but I'm hoping there can be a happy medium.
Once a minute sounds right to me. But if seeing "stale" data for 50 seconds is a major concern, then perhaps you need it more frequently in your case.
精彩评论