0

I am unhappy with the speed of uploading files to the server through OkHttp. I conducted the following experience: closed the program, opened it again. I installed the URL https://httpbin.org/post and started to measure the time. On uploading the first picture it took 3000+ ms. Next I sent another picture (another one, but approximately the same in size) without sending the program. The uploading of this picture took <1000ms. Each next picture was sent about the same time. Ok, I closed the program, opened it and repeated the experiment. Indeed, the first picture is sent from two to three times slower than the next. I initialize okHttpClient in the Application and then I use it in the entire application. Tell me please, what could be the reason for this behavior and how can I speed up the loading of files?

Umy
  • 423
  • 4
  • 9

2 Answers2

0

Whats going on is probably caching, or the program okhttclient has to run so task on its first go around.

sdfbhg
  • 109
  • 5
0

It’s HTTP connection pooling that is saving you 2 seconds on subsequent requests. The initial slow call probably indicates a long round-trip-time between client and server.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128