[wp-hackers] Long Polling, Ajax and WordPress
hal at burgiss.net
Tue Nov 1 13:34:24 UTC 2011
On Mon, Oct 31, 2011 at 10:22 AM, Alex Hempton-Smith
<hempsworth at gmail.com>wrote:
> Hi all,
> The project I'm working on requires an 'activity stream' of WordPress posts
> to be updated live, via Ajax.
> I've read a lot about long polling, Comet etc. but I've found it hard to
> replicate. The code I'm using now essentially polls WordPress every 10
> seconds to check if there are new posts, and then appends them to the top
> a list. This can't be very efficient, as most of the time the response from
> the server will be null.
> How have people achieved long-polling, or any other more efficient method
> create live streams with WP?
A different take on this ... since it seems to me a heavy handed use of
resources if there is significant traffic, and the data could be cached
(although a very short lived cache), and that way you don't have
potentially many clients running the same query every few seconds. So, I
would think about a shell script that builds the cache server side:
while :; do
More information about the wp-hackers