简体   繁体   中英

Are small http requests faster?

I'm implementing an autocomplete-style search in my webapp. Every character that the user types will trigger a search request to the server. The requests and responses must be fast. Milliseconds matter.

As part of the app, I'm considering adding a custom request header. Unfortunately, this extra header will take another 150 bytes. The request itself will be only a short URL, plus a few bytes in the POST body, plus standard headers send automatically by the browser.

Will the custom header affect the speed much?

On one hand, it seems obvious that it would. A bigger request will take longer for the browser to process and send.

On the other hand, the speed difference might be negligible. There might be a lot of other network overhead along the way.

(I'm not concerned about the time it takes the server to process the header. It's definitely going to be well less than a millisecond.)

Will the custom header affect the speed much?

The usual answer: what happened when you tested it?

No. It won't affect it much unless your code is really, really slow (and you've said that's not the case). Even with HTTP/2 reusing a connection, the performance should be dominated by the network RTT. The time taken to transfer the data will be small.

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