Reducing connection wait time for APIs in Flutter

0 votes

I'm trying to optimize API response time for my Flutter app. I have an API where I've added server level caching and I'm using Dio for my API needs.

The reponse time when tested on Postman is ~100ms. Getting similar metrics on Chrome developer tools.

The problems is when I measure the response time on Flutter DevTools, all responses are >250ms. Upon checking, I find that there's a connection wait time of ~200ms for every request.

How can I reduce the above wait time for Flutter?

I tried switching libraries and reusing the same https client as suggested here and in the docs of http but the wait time for subsequent requests remained similar.

var client = http.Client();
final res = await client.get(...);

How can I avoid these connection delays and get the optimum performance? If caching the SSL, DNS Lookup etc is the solution, how do I do that in flutter?

Mar 14, 2023 in Android by anonymous
• 780 points
1,775 views

1 answer to this question.

0 votes

To reduce connection wait time for APIs in Flutter, you can:

  1. Use a connection pool to reuse existing connections
  2. Enable compression to reduce the size of requests and responses
  3. Enable SSL pinning to validate SSL certificates
  4. Use a Content Delivery Network (CDN) to cache frequently accessed resources
  5. Use Flutter profiling tools to identify bottlenecks in your code
To know more, join our Flutter Certification Course today.
answered Mar 18, 2023 by pooja

Related Questions In Android

0 votes
1 answer

Reducing Spacing in an Expanded in Flutter Project

To reduce the space around the Expanded ...READ MORE

answered Mar 20, 2023 in Android by vishalini
5,993 views
0 votes
0 answers

Error: No toolchains found in the NDK toolchains folder for ABI with prefix: llvm

I tried to use Gradel (gradlew clean ...READ MORE

Sep 21, 2022 in Android by Edureka
• 13,620 points
429 views
0 votes
1 answer

How get permission for camera in android.(Specifically Marshmallow)?

To begin with, confirm that the user ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 13,620 points
3,738 views
0 votes
0 answers
0 votes
1 answer

How to add https security for Node js?

You need to add the key and cert to the createServer function. const options ...READ MORE

answered Aug 10, 2018 in Blockchain by digger
• 26,740 points
812 views
0 votes
1 answer

Android Shared preferences for creating one time activity

Android offers a variety of options for ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 12,690 points
531 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP