Why is second API call faster than first?
Per Wikipedia: “Persistent connections keep TCP/TLS open after response so next HTTP exchange skips handshake — called keep-alive.”
Like keeping phone line open — second question does not need redial.
- First request does TCP+TLS+HTTP
- Server replies with Connection: keep-alive
- Socket stays open idle
- Second request reuses socket
- Timeout closes after idle
- Saves 1-2 RTT per reuse
- Needs idle timeout
- Head-of-line blocking in HTTP/1.1
- HTTP/2 multiplexes over one
Connection: keep-alive- Built from: HTTP — persistence is HTTP feature
- Related: HTTP Request Response Cycle — cycle benefits
- Related: HTTP Versions — HTTP/1.1 added keep-alive
- Contrasts with: Statelessness — stateless but transport reused
- Leaking sockets — no close on error
- Pooling without limit — too many open