Carga dinámicamente contenido cada 5 segundos
Frecuentes
Visto 54 veces
0
I'm working on Worpress site where is ajax functionality which cause me some worries. Idea is that with ajax we fetch post (just title and one metakey) cada 5-10 segundos (automaticaclly every 10secs and if user hits refresh button on site then immidiately). There might be few hundreds users at same time on the site after publishing newsletter. Other times there's probably only some tens simultenoius users. So the worry is that maybe it cause some performance issues on my webhotel? Could this fetch done other better way?
Ajax part:
$.ajax({
url: 'http://myadmin.com/wp-admin/admin-ajax.php',
type: 'POST',
data: {
'action': 'get_stuff',
'fn': 'get_post_info'
},
dataType: 'JSON',
success:function(data){
// do some append to show it for usrs
},
error: function(errorThrown){
// error case
}
});
There's new content/posts every day 10-50 which should be showed there too.
¡Gracias por toda tu ayuda!
EDIT: What if I get all posts in one request as js array and then just show stuff from the array every 10secs. That way I could avoid this problem?
1 Respuestas
1
If you're refreshing data every 5 or 10 seconds, and if there are a lot of data, there is no surprise to have performance issues. Maybe you should try to use sockets in javascript to communicate with your server. It's a direct connection.
Respondido el 25 de Septiembre de 13 a las 10:09
This is a good place to start if you're going to go with SSE (Server Sent Events) w3schools.com/html/html5_serversentevents.asp - rfoo
What if I get all posts in one request as js array and then just show stuff from the array every 10secs. That way I could avoid this problem? - user2401882
Downloading and handling data could take a long time. - Kyu_
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ajax wordpress performance caching or haz tu propia pregunta.
Maybe you can use APC, memcache or another caching method? - Stephan Vierkant
Hmm, yes maybe i can take look at those. Any good good articles or tutorials of those anywhere? - user2401882
devzone.zend.com/1812/using-apc-with-php - Stephan Vierkant