It is common knowledge now to combine stylesheets and scripts in effort to reduce HTTP Requests. I have 2 questions:
I cannot find the answers to these two questions in all online readings I did, such as Yahoo! Best Practices which states a number of times that HTTP requests are expensive, but never cite why or how.
Thanks in advance.
How Many HTTP Requests Should Web Pages Have? You should strive to keep the number of HTTP requests under 50. If you can get requests below 25, you're doing amazing. By their nature, HTTP requests are not bad.
In the limit middleware function we call the global limiter's Allow() method each time the middleware receives a HTTP request. If there are no tokens left in the bucket Allow() will return false and we send the user a 429 Too Many Requests response.
The HTTP 429 Too Many Requests response status code indicates the user has sent too many requests in a given amount of time ("rate limiting"). A Retry-After header might be included to this response indicating how long to wait before making a new request.
A HTTP request requires a TCP/IP connection to be made (Think, 3-way handshaking handshaking) before it can handle the HTTP request it self
This involves at least a delay of sending the SYN message to the server and getting the SYN/ACK back (It then sends the ACK to OPEN the socket).
So, say the delay between the client and server is uniform both ways and 50ms, that results in a 100ms delay before it can send the HTTP request. It is then another 100ms before it starts getting the actual request back (Sends the request, then server replies).
Of course, you need to also take into consideration that a standard web browser limits the number of concurrent HTTP requests it is processing at the same time. If your requests have to wait, you don't get that handshake time for free (so to say), since you need to wait for another connection to finish as well. Servers play a role as well, depending on how they server the requests.
Hope that makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With