Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XMLHttp request takes long time on first load

    Hi all,

    I am using XMLHttp Request to call a web service and retrieve data from another website. My code looks like this:

    // create an XmlHttp instance
    objHttp = new ActiveXObject("Microsoft.XMLHTTP");

    // Set up the post
    if(async == true) //async is false by default
    {
    objHttp.onreadystatechange = function () { funcPtr(cntrlArray, codeArray, XPathStr) };
    }

    // send the POST to the Web service
    objHttp.open("POST", szUrl, async);
    objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    objHttp.send(strEnvelope);

    The last line (send method) always causes a 50 sec delay on initial page load. On subsequent page loads, the delay is less than 3 sec.

    Is there anything I can to do to speed up the first execution of the ‘send’ method? I’ve tried setting async to true or false, but there isn’t any difference in performance.

    Thanks for the help.
    Last edited by multiplex77; 12-13-2007 at 06:41 AM.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 584 Times in 565 Posts
    since you are using post, it is not a caching problem.

    perhaps the dns lookup is taking a long time?
    subsequent lookups would be cached and therefore quick...

    theres nothing about your code that is suspicious.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the advice. Appreciate it!

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Is this the first request after you run a new build or deploy the project. Certain serverside languages need to compile the page the first time it is hit and you might be seeing that.

    Say you hit the page first time and you get the 50 seconds. If you kill that brower session. Start it up and go back is it still taking the 50 seconds?

    If it does not than that means the only person that will take the hit is the first person to view it. Easy solution is when you deploy the application, make sure to hit the page.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Eric,

    Yes, the page itself (ASP.NET) takes about 2 min to load the first time, but they Javascript (which includes the XMLHttp request) takes an additional 50 sec to execute the first time. Subsequently the page loads are pretty fast (about 3 sec) and the XMLHttp request is also 3-6 secs.

    I'm just trying to see if there's any way the 50 sec XMLHttp request can be reduced. But I take your point that an easy solution would be to make sure to hit a page after the IIS is reset.

    Thanks for the help.

  • #6
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    There is nothing you can do if it is the very first the the page is hit after an IIS restart. The first person that hits a page is going to pay a big penalty. All of the others should not see that issue.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #7
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Already then. Thanks Eric! Appreciate it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •