NSURLConnection take long time for simple request from one specific server

I have issue with one specific server request, it takes around 30 to 40 seconds to start download using NSURLConnection.

I try to debug using Charlse proxy server and find out that server sends responce within 1 to 1.5 seconds but the callback method for NSURLConnection

- (void)connection:(NSURLConnection *)__unused connection didReceiveResponse:


didn't called at that time it wait for around 30 to 40 sec before it called.


So is there any workaround for this or can I get the responce without this waiting time?


I also find out the differance in header of the responce I got with delay and without delay they are as below


Without any delay


{

"Accept-Ranges" = bytes;

"Cache-Control" = "max-age=687749";

Connection = "keep-alive";

"Content-Length" = 35617808;

"Content-Type" = "video/mp4";

Date = "Fri, 11 Sep 2015 07:21:59 GMT";

Etag = "\"ee90ce32a16fc115d0799d686e5fe1b4\"";

Expires = "Sat, 19 Sep 2015 06:24:28 GMT";

"Keep-Alive" = "timeout=20";

"Last-Modified" = "Wed, 09 Sep 2015 13:41:37 GMT";

Server = ucdn;

"X-Timestamp" = "1441806096.99264";

"X-Ureq-ID" = "PYMqMNZBGw7LI3xeAHCTQwJs2FvO0y0xuG3+g5B0KcBzTv1v4kTfwCzHQYgrBEGSJQ0tBMG5L+srffrjBfio1R1ChR+wABEHY92PCg==";

"X-VHostId" = "10000, 200000";

}


With delay


{

"Cache-Control" = "max-age=687430";

Connection = "keep-alive";

"Content-Length" = 1;

"Content-Range" = "bytes 0-0/35617808";

"Content-Type" = "video/mp4";

Date = "Fri, 11 Sep 2015 07:27:18 GMT";

Etag = "\"ee90ce32a16fc115d0799d686e5fe1b4\"";

Expires = "Sat, 19 Sep 2015 06:24:28 GMT";

"Keep-Alive" = "timeout=20";

"Last-Modified" = "Wed, 09 Sep 2015 13:41:37 GMT";

Server = ucdn;

"X-Timestamp" = "1441806096.99264";

"X-Ureq-ID" = "PYMqMNZBGw7LI3xeAHCTQwJs2FvO0y0xuG3+g5B0KcBzTv1v4kTfwCzHQYgrBEGSJQ0tBMG5L+srffrjBfio1R1ChR+wABEHY92PCg==";

"X-VHostId" = "10000, 710000";

}


So basic defferance is the "Content-Length", when this header has wrong value it delays the callback and when it is proper it just give call to the callback.


Please any one knows any workaround or any thinng which can solve this issue or any one have faced this type of issue just prive me information about this.


Thanks in advance for any help 🙂