Reputation: 9084
I am using $.ajax to update some values in the database. when the page makes the ajax call for the first time, it is slow. it is taking like 5 or 6 seconds to return the result. after the first request, it is fast. I am not sure if there is a way to make the first call also fast. if you have any ideas, please let me know.
Thanks, sridhar
Upvotes: 3
Views: 5219
Reputation: 997
If you found the problem on ASP.NET Application
For sure, the first request will always take longer. This overhead loading time come from JIT compiling for the requested app, Except you are pre-compiled the website.
In another word, It was happened only when you set releasing flag to 'Debug' on ASP.NET Application If set it to 'Release' , you will found that it's only first time for each single requested url will slow but next time will going awesome.
(English is not my mother tongue)
Upvotes: 0
Reputation: 1259
If it only happens in IE7, this is because of IE7 rendering slowly. It might only happen the first time since jquery get/ajax will use the request in a way that can be cached by the browser.
Basically, it isn't clear if it's the rendering or the server.
It still could be the server though - query caching (or other kinds of caching) means the query can be slow first time only, then fast.
Upvotes: 0
Reputation: 9084
Thanks for the response. It is not the server side code that is slow. If it is, then it would be slow every time. This is what we did to make it work faster. When the page loads, in the document.ready function we are making a fake webservice call to eliminate the initial delay. Now it is working fine. The server side code is not actually a web service but a page method in asp.net. Page methods can be used as webservices in asp.net. I will run the firefox and see what happens.
Thanks, sridhar.
Upvotes: 0
Reputation: 25159
Install Fiddler for IE, or run the Firebug console in firefox and take a look at the request / response headers. You'll see where the delay happens.
Upvotes: 1
Reputation: 532435
My suspicion would be that the database is doing some caching and subsequent requests are filled from the cache. If this were only happening on the first request of the data, regardless of the data involved, then I would suspect that the web service that you're connecting to needs to be loaded into memory on the first operation.
Upvotes: 2
Reputation: 268324
You should log the server-side script execution time. I agree with John, and suggest you focus on the server rather than jQuery at this moment.
Upvotes: 0
Reputation: 7963
Is your ajax call against an ASP.NET handler? If so, then it's probably from ASP.NET loading the app domain.
Upvotes: 0
Reputation: 78104
What type of service is the method calling? It's probably the service it is calling that is slow, not jQuery.
Upvotes: 1