I have a web application where the HTTPs handshake take place for every connection and I'm determined to find out why. The HTTP keep-alive is working, so it's something else that forces a request to start a new HTTPs handshake when it shouldn't.
I have something like this (pseudocode):
startNewRequest() {
if (oldRequest)
oldRequest.abort(); // abort old request
oldRequest = $.ajax(); // start new request
}
The request object is XMLHttpRequest returned by jQuery's ajax method. Everytime when I start a request, I abort for the previous request.
My questions is that whether this would force a new request to start a HTTP handshake because the old one hasn't been completed. The requests are regular POST. Do I need to explicit wait for about() to complete before starting off a new request so to take advantage of the HTTP keep alive?
I do get a call in the error callback for $.ajax() for every request I abort. Do I need to start a new request only after I get a callback in the error handler?
Use complete or error in $.ajax
$.ajax({
url : RequestUrl,
complete : function(){
// Do something when request complete
}
});
$.ajax({
url : RequestUrl,
error: function(){
// Do something when an error occurred when the request is done
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With