{"id":8084,"date":"2022-07-25T09:54:10","date_gmt":"2022-07-25T01:54:10","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=8084"},"modified":"2022-07-26T04:55:41","modified_gmt":"2022-07-25T20:55:41","slug":"linux-web-http2","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-web-http2.html","title":{"rendered":"\u63ed\u79d8 HTTP\/2 \u5934\u90e8\u538b\u7f29\u6280\u672f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6211\u4eec\u77e5\u9053\uff0cHTTP\/2 \u534f\u8bae\u7531\u4e24\u4e2a RFC \u7ec4\u6210\uff1a\u4e00\u4e2a\u662f RFC 7540\uff0c\u63cf\u8ff0\u4e86 HTTP\/2 \u534f\u8bae\u672c\u8eab\uff1b\u4e00\u4e2a\u662f RFC 7541\uff0c\u63cf\u8ff0\u4e86 HTTP\/2 \u534f\u8bae\u4e2d\u4f7f\u7528\u7684\u5934\u90e8\u538b\u7f29\u6280\u672f\u3002\u672c\u6587\u5c06\u901a\u8fc7\u5b9e\u9645\u6848\u4f8b\u5e26\u9886\u5927\u5bb6\u8be6\u7ec6\u5730\u8ba4\u8bc6 HTTP\/2 \u5934\u90e8\u538b\u7f29\u8fd9\u95e8\u6280\u672f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e3a\u4ec0\u4e48\u8981\u538b\u7f29<\/strong><\/div>\n

\u5728 HTTP\/1 \u4e2d\uff0cHTTP \u8bf7\u6c42\u548c\u54cd\u5e94\u90fd\u662f\u7531\u300c\u72b6\u6001\u884c\u3001\u8bf7\u6c42 \/ \u54cd\u5e94\u5934\u90e8\u3001\u6d88\u606f\u4e3b\u4f53\u300d\u4e09\u90e8\u5206\u7ec4\u6210\u3002\u4e00\u822c\u800c\u8a00\uff0c\u6d88\u606f\u4e3b\u4f53\u90fd\u4f1a\u7ecf\u8fc7 gzip \u538b\u7f29\uff0c\u6216\u8005\u672c\u8eab\u4f20\u8f93\u7684\u5c31\u662f\u538b\u7f29\u8fc7\u540e\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08\u4f8b\u5982\u56fe\u7247\u3001\u97f3\u9891\uff09\uff0c\u4f46\u72b6\u6001\u884c\u548c\u5934\u90e8\u5374\u6ca1\u6709\u7ecf\u8fc7\u4efb\u4f55\u538b\u7f29\uff0c\u76f4\u63a5\u4ee5\u7eaf\u6587\u672c\u4f20\u8f93\u3002\u968f\u7740 Web \u529f\u80fd\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u6bcf\u4e2a\u9875\u9762\u4ea7\u751f\u7684\u8bf7\u6c42\u6570\u4e5f\u8d8a\u6765\u8d8a\u591a\uff0c\u6839\u636e HTTP Archive \u7684\u7edf\u8ba1\uff0c\u5f53\u524d\u5e73\u5747\u6bcf\u4e2a\u9875\u9762\u90fd\u4f1a\u4ea7\u751f\u4e0a\u767e\u4e2a\u8bf7\u6c42\u3002\u8d8a\u6765\u8d8a\u591a\u7684\u8bf7\u6c42\u5bfc\u81f4\u6d88\u8017\u5728\u5934\u90e8\u7684\u6d41\u91cf\u8d8a\u6765\u8d8a\u591a\uff0c\u5c24\u5176\u662f\u6bcf\u6b21\u90fd\u8981\u4f20\u8f93 UserAgent\u3001Cookie \u8fd9\u7c7b\u4e0d\u4f1a\u9891\u7e41\u53d8\u52a8\u7684\u5185\u5bb9\uff0c\u5b8c\u5168\u662f\u4e00\u79cd\u6d6a\u8d39\u3002<\/p>\n

\u4ee5\u4e0b\u662f\u6211\u968f\u624b\u6253\u5f00\u7684\u4e00\u4e2a\u9875\u9762\u7684\u6293\u5305\u7ed3\u679c\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u4f20\u8f93\u5934\u90e8\u7684\u7f51\u7edc\u5f00\u9500\u8d85\u8fc7 100kb\uff0c\u6bd4 HTML \u8fd8\u591a\uff1a<\/p>\n

\"linux_web_http2_02\"<\/p>\n

\u4e0b\u9762\u662f\u5176\u4e2d\u4e00\u4e2a\u8bf7\u6c42\u7684\u660e\u7ec6\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u4e3a\u4e86\u83b7\u5f97 58 \u5b57\u8282\u7684\u6570\u636e\uff0c\u5728\u5934\u90e8\u4f20\u8f93\u4e0a\u82b1\u8d39\u4e86\u597d\u51e0\u500d\u7684\u6d41\u91cf\uff1a<\/p>\n

\"linux_web_http2_03\"<\/p>\n

HTTP\/1 \u65f6\u4ee3\uff0c\u4e3a\u4e86\u51cf\u5c11\u5934\u90e8\u6d88\u8017\u7684\u6d41\u91cf\uff0c\u6709\u5f88\u591a\u4f18\u5316\u65b9\u6848\u53ef\u4ee5\u5c1d\u8bd5\uff0c\u4f8b\u5982\u5408\u5e76\u8bf7\u6c42\u3001\u542f\u7528 Cookie-Free \u57df\u540d\u7b49\u7b49\uff0c\u4f46\u662f\u8fd9\u4e9b\u65b9\u6848\u6216\u591a\u6216\u5c11\u4f1a\u5f15\u5165\u4e00\u4e9b\u65b0\u7684\u95ee\u9898\uff0c\u8fd9\u91cc\u4e0d\u5c55\u5f00\u8ba8\u8bba\u3002<\/p>\n

\u538b\u7f29\u540e\u7684\u6548\u679c<\/strong><\/div>\n

\u9996\u5148\u76f4\u63a5\u4e0a\u56fe\u3002\u4e0b\u56fe\u9009\u4e2d\u7684 Stream \u662f\u9996\u6b21\u8bbf\u95ee\u672c\u7ad9\uff0c\u6d4f\u89c8\u5668\u53d1\u51fa\u7684\u8bf7\u6c42\u5934\uff1a<\/p>\n

\"linux_web_http2_04\"<\/p>\n

\u4ece\u56fe\u7247\u4e2d\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a HEADERS \u6d41\u7684\u957f\u5ea6\u662f 206 \u4e2a\u5b57\u8282\uff0c\u800c\u89e3\u7801\u540e\u7684\u5934\u90e8\u957f\u5ea6\u6709 451 \u4e2a\u5b57\u8282\u3002\u7531\u6b64\u53ef\u89c1\uff0c\u538b\u7f29\u540e\u7684\u5934\u90e8\u5927\u5c0f\u51cf\u5c11\u4e86\u4e00\u534a\u591a\u3002<\/p>\n

\u7136\u800c\u8fd9\u5c31\u662f\u5168\u90e8\u5417\uff1f\u518d\u4e0a\u4e00\u5f20\u56fe\u3002\u4e0b\u56fe\u9009\u4e2d\u7684 Stream \u662f\u70b9\u51fb\u672c\u7ad9\u94fe\u63a5\u540e\uff0c\u6d4f\u89c8\u5668\u53d1\u51fa\u7684\u8bf7\u6c42\u5934\uff1a<\/p>\n

\"linux_web_http2_05\"<\/p>\n

\u53ef\u4ee5\u770b\u5230\u8fd9\u4e00\u6b21\uff0cHEADERS \u6d41\u7684\u957f\u5ea6\u53ea\u6709 49 \u4e2a\u5b57\u8282\uff0c\u4f46\u662f\u89e3\u7801\u540e\u7684\u5934\u90e8\u957f\u5ea6\u5374\u6709 470 \u4e2a\u5b57\u8282\u3002\u8fd9\u4e00\u6b21\uff0c\u538b\u7f29\u540e\u7684\u5934\u90e8\u5927\u5c0f\u51e0\u4e4e\u53ea\u6709\u539f\u59cb\u5927\u5c0f\u7684 1\/10\u3002<\/p>\n

\u4e3a\u4ec0\u4e48\u524d\u540e\u4e24\u6b21\u5dee\u8ddd\u8fd9\u4e48\u5927\u5462\uff1f\u6211\u4eec\u628a\u4e24\u6b21\u7684\u5934\u90e8\u4fe1\u606f\u5c55\u5f00\uff0c\u67e5\u770b\u540c\u4e00\u4e2a\u5b57\u6bb5\u4e24\u6b21\u4f20\u8f93\u6240\u5360\u7528\u7684\u5b57\u8282\u6570\uff1a<\/p>\n

\"linux_web_http2_06\"<\/p>\n

\"linux_web_http2_07\"
\n\u5bf9\u6bd4\u540e\u53ef\u4ee5\u53d1\u73b0\uff0c\u7b2c\u4e8c\u6b21\u7684\u8bf7\u6c42\u5934\u90e8\u4e4b\u6240\u4ee5\u975e\u5e38\u5c0f\uff0c\u662f\u56e0\u4e3a\u5927\u90e8\u5206\u952e\u503c\u5bf9\u53ea\u5360\u7528\u4e86\u4e00\u4e2a\u5b57\u8282\u3002\u5c24\u5176\u662f UserAgent\u3001Cookie \u8fd9\u6837\u7684\u5934\u90e8\uff0c\u9996\u6b21\u8bf7\u6c42\u4e2d\u9700\u8981\u5360\u7528\u5f88\u591a\u5b57\u8282\uff0c\u540e\u7eed\u8bf7\u6c42\u4e2d\u90fd\u53ea\u9700\u8981\u4e00\u4e2a\u5b57\u8282\u3002<\/p>\n

\u6280\u672f\u539f\u7406<\/strong><\/div>\n

\u4e0b\u9762\u8fd9\u5f20\u622a\u56fe\uff0c\u53d6\u81ea Google \u7684\u6027\u80fd\u4e13\u5bb6 Ilya Grigorik \u5728 Velocity 2015 \u2022 SC \u4f1a\u8bae\u4e2d\u5206\u4eab\u7684\u300cHTTP\/2 is here, let's optimize!\u300d\uff0c\u975e\u5e38\u76f4\u89c2\u5730\u63cf\u8ff0\u4e86 HTTP\/2 \u4e2d\u5934\u90e8\u538b\u7f29\u7684\u539f\u7406\uff1a<\/p>\n

\"linux_web_http2_08\"<\/p>\n

\u6211\u518d\u7528\u901a\u4fd7\u7684\u8bed\u8a00\u89e3\u91ca\u4e0b\uff0c\u5934\u90e8\u538b\u7f29\u9700\u8981\u5728\u652f\u6301 HTTP\/2 \u7684\u6d4f\u89c8\u5668\u548c\u670d\u52a1\u7aef\u4e4b\u95f4\uff1a\u7ef4\u62a4\u4e00\u4efd\u76f8\u540c\u7684\u9759\u6001\u5b57\u5178\uff08Static Table\uff09\uff0c\u5305\u542b\u5e38\u89c1\u7684\u5934\u90e8\u540d\u79f0\uff0c\u4ee5\u53ca\u7279\u522b\u5e38\u89c1\u7684\u5934\u90e8\u540d\u79f0\u4e0e\u503c\u7684\u7ec4\u5408\uff1b<\/p>\n