Knowledge

HTTP persistent connection

Source đź“ť

500: 31: 478:
If the client does not close the connection when all of the data it needs has been received, the resources needed to keep the connection open on the server will be unavailable for other clients. How much this affects the server's availability and how long the resources are unavailable depend on the
376:
do not use separate keepalive messages, they just allow multiple requests to use a single connection. However, the default connection timeout of Apache httpd 1.3 and 2.0 is as little as 15 seconds and just 5 seconds for Apache httpd 2.2 and above. The advantage of a short timeout is the ability to
486:
can occur where the client sends a request to the server at the same time that the server closes the TCP connection. A server should send a 408 Request Timeout status code to the client immediately before closing the connection. When a client receives the 408 status code, after having sent the
469:
but in the words of RFC 7230 "this was found to be impractical for many applications... instead... be conservative when opening multiple connections". These guidelines are intended to improve HTTP response times and avoid congestion. If HTTP pipelining is correctly implemented, there is no
346:
When the server receives this request and generates a response, if it supports keep-alive then it also adds the same above header to the response. Following this, the connection is not dropped, but is instead kept open. When the client sends another request, it uses the same connection.
336:
Since at least late 1995, developers of popular products (browsers, web servers, etc.) using HTTP/1.0, started to add an unofficial extension (to the protocol) named "keep-alive" in order to allow the reuse of a connection for multiple requests/responses.
363:
Since 1997, the various versions of HTTP/1.1 specifications acknowledged the usage of this unofficial extension and included a few caveats regarding the interoperability between HTTP/1.0 (keep-alive) and HTTP/1.1 clients / servers.
541:, the number of simultaneous connections can be customized (per-server, per-proxy, total). Persistent connections time out after 115 seconds (1.92 minutes) of inactivity which is changeable via the configuration. 388:
Keepalive makes it difficult for the client to determine where one response ends and the next response begins, particularly during pipelined HTTP operation. This is a serious problem when
534:
versions 6 and 7 use two persistent connections while version 8 uses six. Persistent connections time out after 60 seconds of inactivity which is changeable via the Windows Registry.
487:
request, it may open a new connection to the server and re-send the request. Not all clients will re-send the request, and many that do will only do so if the request has an
557:, which establishes a persistent HTTP connection, thereby allowing the underlying TCP connection to be reused, which can result in a significant performance increase. 634: 798: 465:, "a client ought to limit the number of simultaneous open connections that it maintains to a given server". The previous version of the HTTP/1.1 specification 488: 710: 316:
protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection.
377:
deliver multiple components of a web page quickly while not consuming resources to run multiple server processes or threads for too long.
870: 840:
Nielssen, Frystyk Henryk; Gettys, James; Baird-Smith, Anselm; Prud’hommeaux, Eric; Wium Lie, Håkon; Lilley, Chris (October 1997),
350:
This will continue until either the client or the server decides that the conversation is over and in this case they omit the
470:
performance benefit to be gained from additional connections, while additional connections may cause issues with congestion.
1061: 642: 674: 664: 769: 433: 609: 277: 451: 305: 1007: 220: 422: 309: 215: 122: 1032:
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing, Connection Management, Persistence
382: 312:/responses, as opposed to opening a new connection for every single request/response pair. The newer 165: 944: 756: 745: 734: 714: 251: 826: 393: 246: 1041: 1036: 404:
bit is set at the end of each response so that the client knows where the next response begins.
1046: 841: 241: 418: 414: 236: 986: 812: 698: 596: 524: 372:
In HTTP 1.1, all connections are considered persistent unless declared otherwise. The HTTP
8: 635:"The TCP/IP Guide - HTTP Persistent Connection Establishment, Management and Termination" 520: 905: 576: 447: 270: 575:, which allows out-of-order pipelining of requests and responses, and also predictive 853: 670: 531: 516: 909: 889: 799:"HTTP: What are the relations between pipelining, keep alive and server sent events" 662: 897: 466: 45: 923: 354:
header from the last message sent or, better, they add the keyword "close" to it:
16:
Using a single TCP connection to send and receive multiple HTTP requests/responses
1031: 888:
Fielding, Roy T.; Reschke, Julian (June 2014). Fielding, R.; Reschke, J. (eds.).
566: 462: 440: 156: 663:
David Gourley; Brian Totty; Marjorie Sayer; Anshu Aggarwal; Sailu Reddy (2002).
340:
If the client supports keep-alive, it adds an additional header to the request:
699:
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing, Persistence
483: 392:
cannot be used due to streaming. To solve this problem, HTTP 1.1 introduced a
1055: 857: 508: 499: 263: 141: 151: 146: 113: 108: 103: 98: 93: 83: 78: 73: 64: 966:"How to change the default keep-alive time-out value in Internet Explorer" 666:
HTTP: The Definitive Guide. (excerpt of chapter: "Persistent Connections")
965: 457:
Errors can be reported without the penalty of closing the TCP connection.
131: 88: 839: 777: 569:, whereby multiple requests can be sent without waiting for a response 901: 136: 199: 194: 189: 184: 179: 174: 538: 512: 890:"Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content" 572: 360:
After that the connection is closed following specified rules.
313: 50: 432:
usage and round-trips because of fewer new connections and
30: 380: 291: 55: 22: 1037:
Persistent Connection Behavior of Popular Browsers (dated)
597:
Hypertext Transfer Protocol (HTTP/1.0): Overall Operation
429: 842:"Network Performance Effects of HTTP/1.1, CSS1, and PNG" 871:"How do browsers handle HTTP keepalive race condition?" 1047:
Network Performance Effects of HTTP/1.1, CSS1, and PNG
924:"Opera 4.0 Upgrades File Exchange: Includes HTTP 1.1" 711:"Apache HTTP Server 1.3 – KeepAliveTimeout Directive" 813:"HTTP Streaming (or Chunked vs Store & Forward)" 757:
Apache HTTP Server 2.4 – KeepAliveTimeout Directive
746:
Apache HTTP Server 2.2 – KeepAliveTimeout Directive
735:
Apache HTTP Server 2.0 – KeepAliveTimeout Directive
1053: 887: 689: 694: 692: 503:Schema of multiple vs. persistent connection. 329:Under HTTP 1.0, connections should always be 271: 767: 333:by the server after sending the response. 278: 264: 846:ACM SIGCOMM Computer Communication Review 479:server's architecture and configuration. 498: 308:connection to send and receive multiple 1008:"Requests.AdvancedUsage.SessionObjects" 579:of content before it has been requested 1054: 494: 13: 1010:. ©MMXVIX. A Kenneth Reitz Project 607: 507:All modern web browsers including 14: 1073: 1025: 987:"Network.http.keep-alive.timeout" 544: 200:451 Unavailable for Legal Reasons 473: 304:, is the idea of using a single 29: 1042:Apache HTTPD Keep-Alive Support 1000: 979: 958: 937: 916: 881: 863: 833: 819: 805: 791: 761: 208:Security access control methods 947:. Stevesouders.com. 2008-03-10 750: 739: 728: 703: 656: 627: 601: 590: 467:stated specific maximum values 1: 583: 407: 926:. Opera Software. 2000-03-28 527:use persistent connections. 319: 221:Digest access authentication 7: 1062:Hypertext Transfer Protocol 560: 417:in subsequent requests (no 367: 324: 216:Basic access authentication 10: 1078: 443:of requests and responses. 827:"Chunked Transfer Coding" 383:chunked transfer encoding 252:HTTP parameter pollution 229:Security vulnerabilities 968:. Microsoft. 2007-10-27 669:. O'Reilly Media, inc. 394:chunked transfer coding 343:Connection: keep-alive 247:HTTP response splitting 945:"IE8 speeds things up" 504: 489:idempotent HTTP method 374:persistent connections 242:HTTP request smuggling 502: 463:RFC 7230, section 6.4 302:HTTP connection reuse 294:persistent connection 237:HTTP header injection 175:301 Moved Permanently 166:Response status codes 495:Use in web browsers 780:on January 6, 2010 639:www.tcpipguide.com 610:"HTTP_Connection?" 555:requests.Session() 505: 448:network congestion 357:Connection: close 989:. Mozillazine.org 770:"Httpd/KeepAlive" 768:Multiple (wiki). 553:library contains 532:Internet Explorer 517:Internet Explorer 288: 287: 1069: 1019: 1018: 1016: 1015: 1004: 998: 997: 995: 994: 983: 977: 976: 974: 973: 962: 956: 955: 953: 952: 941: 935: 934: 932: 931: 920: 914: 913: 902:10.17487/RFC7231 894:IETF Datatracker 885: 879: 878: 867: 861: 860: 837: 831: 830: 823: 817: 816: 809: 803: 802: 795: 789: 788: 786: 785: 776:. Archived from 765: 759: 754: 748: 743: 737: 732: 726: 725: 723: 722: 713:. Archived from 707: 701: 696: 687: 686: 684: 683: 660: 654: 653: 651: 650: 641:. Archived from 631: 625: 624: 622: 620: 605: 599: 594: 556: 552: 523:(since 4.0) and 403: 399: 391: 353: 280: 273: 266: 33: 19: 18: 1077: 1076: 1072: 1071: 1070: 1068: 1067: 1066: 1052: 1051: 1028: 1023: 1022: 1013: 1011: 1006: 1005: 1001: 992: 990: 985: 984: 980: 971: 969: 964: 963: 959: 950: 948: 943: 942: 938: 929: 927: 922: 921: 917: 886: 882: 869: 868: 864: 838: 834: 825: 824: 820: 811: 810: 806: 797: 796: 792: 783: 781: 766: 762: 755: 751: 744: 740: 733: 729: 720: 718: 709: 708: 704: 697: 690: 681: 679: 677: 661: 657: 648: 646: 633: 632: 628: 618: 616: 606: 602: 595: 591: 586: 567:HTTP pipelining 563: 554: 550: 547: 497: 476: 452:TCP connections 441:HTTP pipelining 410: 401: 397: 396:that defines a 389: 386: 381:Keepalive with 370: 358: 351: 344: 327: 322: 298:HTTP keep-alive 284: 157:X-Forwarded-For 65:Request methods 17: 12: 11: 5: 1075: 1065: 1064: 1050: 1049: 1044: 1039: 1034: 1027: 1026:External links 1024: 1021: 1020: 999: 978: 957: 936: 915: 880: 877:. Mar 6, 2017. 875:Stack Overflow 862: 832: 818: 804: 790: 760: 749: 738: 727: 702: 688: 675: 655: 626: 600: 588: 587: 585: 582: 581: 580: 570: 562: 559: 546: 545:Implementation 543: 519:(since 4.01), 496: 493: 484:race condition 475: 472: 459: 458: 455: 444: 437: 434:TLS handshakes 426: 409: 406: 390:Content-Length 385: 379: 369: 366: 356: 342: 326: 323: 321: 318: 296:, also called 286: 285: 283: 282: 275: 268: 260: 257: 256: 255: 254: 249: 244: 239: 231: 230: 226: 225: 224: 223: 218: 210: 209: 205: 204: 203: 202: 197: 192: 187: 182: 177: 169: 168: 162: 161: 160: 159: 154: 149: 144: 139: 134: 126: 125: 119: 118: 117: 116: 111: 106: 101: 96: 91: 86: 81: 76: 68: 67: 61: 60: 59: 58: 53: 48: 43: 35: 34: 26: 25: 15: 9: 6: 4: 3: 2: 1074: 1063: 1060: 1059: 1057: 1048: 1045: 1043: 1040: 1038: 1035: 1033: 1030: 1029: 1009: 1003: 988: 982: 967: 961: 946: 940: 925: 919: 911: 907: 903: 899: 895: 891: 884: 876: 872: 866: 859: 855: 851: 847: 843: 836: 828: 822: 814: 808: 800: 794: 779: 775: 771: 764: 758: 753: 747: 742: 736: 731: 717:on 2015-10-26 716: 712: 706: 700: 695: 693: 678: 676:9781565925090 672: 668: 667: 659: 645:on 2017-05-21 644: 640: 636: 630: 615: 614:Google Groups 611: 608:Gildor, Dan. 604: 598: 593: 589: 578: 574: 571: 568: 565: 564: 558: 542: 540: 535: 533: 528: 526: 522: 518: 514: 510: 509:Google Chrome 501: 492: 490: 485: 480: 474:Disadvantages 471: 468: 464: 461:According to 456: 453: 449: 445: 442: 438: 435: 431: 427: 424: 420: 416: 412: 411: 405: 395: 384: 378: 375: 365: 361: 355: 352:"Connection:" 348: 341: 338: 334: 332: 317: 315: 311: 310:HTTP requests 307: 303: 299: 295: 293: 281: 276: 274: 269: 267: 262: 261: 259: 258: 253: 250: 248: 245: 243: 240: 238: 235: 234: 233: 232: 228: 227: 222: 219: 217: 214: 213: 212: 211: 207: 206: 201: 198: 196: 195:404 Not Found 193: 191: 190:403 Forbidden 188: 186: 185:303 See Other 183: 181: 178: 176: 173: 172: 171: 170: 167: 164: 163: 158: 155: 153: 150: 148: 145: 143: 140: 138: 135: 133: 130: 129: 128: 127: 124: 123:Header fields 121: 120: 115: 112: 110: 107: 105: 102: 100: 97: 95: 92: 90: 87: 85: 82: 80: 77: 75: 72: 71: 70: 69: 66: 63: 62: 57: 54: 52: 49: 47: 44: 42: 39: 38: 37: 36: 32: 28: 27: 24: 21: 20: 1012:. Retrieved 1002: 991:. Retrieved 981: 970:. Retrieved 960: 949:. Retrieved 939: 928:. Retrieved 918: 893: 883: 874: 865: 849: 845: 835: 829:. June 1999. 821: 807: 793: 782:. Retrieved 778:the original 773: 763: 752: 741: 730: 719:. Retrieved 715:the original 705: 680:. Retrieved 665: 658: 647:. Retrieved 643:the original 638: 629: 617:. Retrieved 613: 603: 592: 548: 536: 530:By default, 529: 506: 481: 477: 460: 387: 373: 371: 362: 359: 349: 345: 339: 335: 330: 328: 301: 297: 290: 289: 147:HTTP referer 40: 619:17 November 419:handshaking 46:Compression 41:Persistence 1014:2023-04-22 993:2009-07-17 972:2009-07-17 951:2009-07-17 930:2009-07-08 784:2010-01-30 721:2015-01-28 682:2021-10-18 649:2017-12-31 584:References 423:slow start 408:Advantages 402:last-chunk 398:last-chunk 858:0146-4833 549:Python's 400:bit. The 320:Operation 180:302 Found 1056:Category 910:14399078 774:Docforge 561:See also 551:requests 446:Reduced 439:Enables 428:Reduced 413:Reduced 368:HTTP 1.1 325:HTTP 1.0 142:Location 577:pushing 539:Firefox 513:Firefox 482:Also a 450:(fewer 421:and no 415:latency 109:CONNECT 74:OPTIONS 908:  856:  673:  573:HTTP/2 525:Safari 331:closed 314:HTTP/2 132:Cookie 99:DELETE 906:S2CID 852:(4), 521:Opera 300:, or 114:PATCH 104:TRACE 51:HTTPS 854:ISSN 671:ISBN 621:2023 292:HTTP 137:ETag 89:POST 84:HEAD 56:QUIC 23:HTTP 898:doi 537:In 430:CPU 306:TCP 152:DNT 94:PUT 79:GET 1058:: 904:. 896:. 892:. 873:. 850:27 848:, 844:, 772:. 691:^ 637:. 612:. 515:, 511:, 491:. 454:). 425:). 1017:. 996:. 975:. 954:. 933:. 912:. 900:: 815:. 801:. 787:. 724:. 685:. 652:. 623:. 436:. 279:e 272:t 265:v

Index

HTTP

Persistence
Compression
HTTPS
QUIC
Request methods
OPTIONS
GET
HEAD
POST
PUT
DELETE
TRACE
CONNECT
PATCH
Header fields
Cookie
ETag
Location
HTTP referer
DNT
X-Forwarded-For
Response status codes
301 Moved Permanently
302 Found
303 See Other
403 Forbidden
404 Not Found
451 Unavailable for Legal Reasons

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑