|
|
Programming Question - WordPress Smart Refresh
|
|
|
|
Posting Junkie
Join Date: Feb 2000
Location: Washington, DC
Status:
Offline
|
|
OK, I'm not a programmer, but I have a rather basic (aren't they all?) question. So, I have a WordPress blog connected to an event screen (think TV). I'd like the browser connected to the TV to refresh when new content is added to the WordPress site (currently, it simply refreshes every 15 minutes). The new method only needs to check every 2-5 minutes, but currently, the dumb refresh pulls over ~4-10mb per update. Not massive, but it could grow over time.
I'm wide open to suggestions, input, etc.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Feb 2000
Location: Nashua NH, USA
Status:
Offline
|
|
Poll a dirty flag every 2 minutes and use that to determine if a full get is needed? I don't know wordpress though.
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Feb 2000
Location: Washington, DC
Status:
Offline
|
|
Would you do that in javascript or something else?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
This would require JavaScript and AJAX calls being called over set intervals. It would be hard to do this without interrupting a post you were reading.
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Feb 2000
Location: Washington, DC
Status:
Offline
|
|
Originally Posted by besson3c
This would require JavaScript and AJAX calls being called over set intervals. It would be hard to do this without interrupting a post you were reading.
besson3c, thanks! Considering this is an event monitor (that might... MIGHT be updated 1-2 a day, max, and that's a big might) I'm a little less worried about upsetting the viewing experience. Also, most of the updates would happen in the middle of the night or in "emergency" (aka, not in any way an emergency) situations.
Would you be able to point me in the right direction regarding how this might be accomplished?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by mitchell_pgh
besson3c, thanks! Considering this is an event monitor (that might... MIGHT be updated 1-2 a day, max, and that's a big might) I'm a little less worried about upsetting the viewing experience. Also, most of the updates would happen in the middle of the night or in "emergency" (aka, not in any way an emergency) situations.
Would you be able to point me in the right direction regarding how this might be accomplished?
Sure!
I would create a new URL/WP page called something like "/eventrefresh" and assign it to a custom template. In this template I would call query_posts() to loop over all of your posts, finding the most recent update date. I would compare this update date to the last update date you have stored in a PHP session variable (or database table, if you'd prefer to be able to quit the browser and therefore destroy the current session). If an update is available you'd output the update date to signal to your AJAX call that a page refresh is needed.
On the Javascript side you would trigger your AJAX call wrapped in a setInterval() wrapper, i.e.
Code:
var refreshtimer = setInterval(function() {
... your AJAX call to /eventrefresh ...
}, 5000);
where 5000 is the interval your AJAX call would fire in milliseconds. I suspect that you'd be doing this Javascript in jQuery, but here is the AJAX call in YUI (where my brain is right now):
Code:
YUI().use('io-base', function(Y) {
var refreshtimer = setInterval(function() {
var cfg = {
method:'post',
on: {
complete:function(id, transport) {
if (transport.responseText) {
location.reload();
}
}
}
}
Y.io('/eventrefresh', cfg);
}, 5000);
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|