[wp-hackers] Long Polling, Ajax and WordPress

Dagan Henderson Dagan.Henderson at epyllion.com
Tue Nov 1 13:46:11 UTC 2011


>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:

Rather than a long-running shell script (which violates some hosting provider TOS and requires SSH access), why not hook into 'edit_post,'  which is called for comments and post edits alike?

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Hal Burgiss
Sent: Tuesday, November 01, 2011 6:34 AM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Long Polling, Ajax and WordPress

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 of 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 to 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
   $mysql_build_cache
   sleep 10
done

--
Hal
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list