2

An app we have in production has a lot of http requests dealing with authorization, fetching data, and posting data to the backend. It's been reported to us that it load times were lengthy and I figured it was because of the way I was using the http package all throughout the app.

What I know according to the http package...

If you're making multiple requests to the same server, you can keep open a persistent connection by using a Client rather than making one-off requests. If you do this, make sure to close the client when you're done.

So far, I've only used the Client class on our bag screen which first gets the items a user have in their cart, then calls an endpoint for each product once. Meaning that if a user had N items in their bag, the app does N+1 calls.

I'm wondering if I should persist a connection all throughout the app lifecycle using the http.Client and if that's proper practice. I've also recently read about http Keep-Alive and I wonder if I should just include that header in each of my requests.

Louise
  • 31
  • 4

0 Answers0