1

I have code that fires an ICallbackEventHandler every 1000ms. When I run this code locally the data responds quick like every 1 second.

I then uploaded this on the server and sometimes the data responds 1 second and sometimes 3 seconds and then sometimes 6-7 seconds, why is this?

The bit of code that makes this recursive call every 1 second to the server is below:

function MessageServerResponse(param, context) {
    if (param.length > 0) {
        var splitParam = param.split("~");
        var id = splitParam[0];
        var data= splitParam[1];

        $('#' + id).prepend(data);
    }

    setTimeout("MessageServerRequest();", 1000);
}
sisve
  • 19,501
  • 3
  • 53
  • 95
redoc01
  • 2,107
  • 5
  • 32
  • 64

1 Answers1

1

if u r the only person who use server, the response would be always 1 second. and u cannot expect client to dedicately response your script

1 of my trick to make it faster

  • if u use normal <form> postback put as less as u can in form. more html in form means more data transfer
  • if u use updatepanel just keep it small or make dedicate update panel to boost performance
  • for jquery, i'd suggest $.ajax({cache:true})
Bonshington
  • 3,970
  • 2
  • 25
  • 20
  • Thankyou for replying and taking time to answe rmy question. I just wanted to also ask maybe it is my script file, the script file contains a lot of javascript. I havent really made much of the Javascript in a reusable manner yet as im still working on other things. Could it be that making the script file much more lighter and code reusable might speed up the response? – redoc01 Jan 24 '11 at 14:03
  • from my experience, mostly ViewState causing performance drop. Bigger ViewState cause more load in each transfer. – Bonshington Jan 24 '11 at 14:21
  • i dont really need viewstate on the page, if i enableviewstate to false could i give that a go? – redoc01 Jan 24 '11 at 15:09
  • (update code sample)its really hard to tell what cause performance drop. Have to try passing something simple, such as simple text. just to test network performance? – Bonshington Feb 02 '11 at 06:46