Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2007, 06:23 AM   PM User | #1
multiplex77
New to the CF scene

 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
multiplex77 is an unknown quantity at this point
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..
multiplex77 is offline   Reply With Quote
Old 12-13-2007, 10:14 AM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 479 Times in 462 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
rnd me is online now   Reply With Quote
Old 12-13-2007, 10:27 AM   PM User | #3
multiplex77
New to the CF scene

 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
multiplex77 is an unknown quantity at this point
Thanks for the advice. Appreciate it!
multiplex77 is offline   Reply With Quote
Old 12-14-2007, 05:30 AM   PM User | #4
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 12-14-2007, 05:36 AM   PM User | #5
multiplex77
New to the CF scene

 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
multiplex77 is an unknown quantity at this point
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.
multiplex77 is offline   Reply With Quote
Old 12-14-2007, 02:02 PM   PM User | #6
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 12-20-2007, 04:45 AM   PM User | #7
multiplex77
New to the CF scene

 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
multiplex77 is an unknown quantity at this point
Already then. Thanks Eric! Appreciate it.
multiplex77 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:51 PM.


Advertisement
Log in to turn off these ads.