Wednesday, 15 May 2013

ruby on rails - Does frequent ajax call kill PC? How can I handle this? -



ruby on rails - Does frequent ajax call kill PC? How can I handle this? -

every 10 seconds, calls ajax reload number of received mails. however, seems macbook getting heated time goes by, when i'm doing nil staying @ same page in application.

how should handle kind of transaction?

refresh_mail_count.js

jquery(document).ready(function () { refreshmail(); }); function refreshmail() { $.ajax({ url: "/messages/refresh_mail", type: "get", datatype: "script", }); }

refresh_mail.js.erb

$('#message_count').html("<%= j(render(:partial => 'layouts/message_received_count', :object => @message_count)) %>"); settimeout(refreshmail,10000);

the cpu gets hot when does work: question - work justified? is, process(es) utilize cpu, , when?

this work not come network request itself, io operation of "low cpu usage", consider might cause work:

the processing response info (excessive/slow dom manipulation), or the web-server itself (slow/inefficient impl.), if running local, or the ajax requests might piling - can lead snowball effect1!

1 create sure only post new request, 10 seconds after recieving previous success/failure callback.

ruby-on-rails ajax ruby-on-rails-3 jquery

No comments:

Post a Comment