简体   繁体   中英

How many fetch requests are too much?

I'm on the newer side of web development. I use React so obviously I focus on client side rendering, but for a certain application I was thinking to make a request to my server for every page (this probably isn't necessary but just a workaround due to ignorance on my part); however, the thought came to me, how many fetch requests are too much?


I want to divide this a little bit, I know different fetch requests can take different amounts of time, a GET request for 1 item of data is faster than a POST request that adds 20 rows and you can't account for all the variations.

But in general,

  1. How long does a fetch request to a server (performing some sort of CRUD operation on the database) take?

** 2. How long does a fetch request to a server (NOT performing any operation to a database) take?**

Option 2 is obviously faster (if we're just imagining simple requests) and I know this can probably vary from server to server, but I think it would be helpful to know, so I can structure my site more efficiently and have some sort of knowledge about this topic?

There is no general way to know how long a request will take, it depends on so many factors like internet speed (assuming it is not a local server), the amount of data being submitted (in a POST) or retrieved, the amount of processing done on the server before returning the response etc.

If you have the answers to all of the above questions you can just calculate the time as a simple calculation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM