开发者

Multiple pages running same polling script

I have a jQuery script in my header that updates the last_active datetime database field every 60 seconds. The problem is, if the user has multiple windows open then t开发者_StackOverflow社区his puts extra pressure on the server as each page is updating after 60 seconds.

I would rather fix this problem without having to resort to frames... if that's even possible.

Any way around this issue?


You can check which IP requests are coming from in your PHP logic, and place a condition that only performs the update from that IP if it has not already been done in the past 60 seconds.


You can do as Will suggested but the problem in the above case is, not all the users use public ip to browse the InterNet. In this case you can try to check the browser version and session ID also with the IP. Then you can even different statistics for the users behind the ISP/Cyber Cafe's with single IP and multiple browsing machines.


Why do you keep such a field? Is it not possible to just maintain the "last_accessed" time whenever a request comes in and use that for your purposes rather than something like what you're doing?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜