《HTTP/2 in Action 中文版》是由電子工業出版社於2020年7月出版圖書,作者是Barry Pollard。本書會教你高效使用HTTP/2需要的所有知識。
基本介紹
- 中文名:HTTP/2 in Action 中文版
- 作者:【美】Barry Pollard
- 譯者:鄭維智
- 出版社:電子工業出版社
- 出版時間:2020年7月
- 頁數:412 頁
- 定價:112 元
- 開本:16 開
- ISBN:9787121386718
內容簡介,圖書目錄,作者簡介,
內容簡介
《HTTP/2 in Action 中文版》以易於理解、方便上手的方式,使用貼近用戶的實例來解釋 HTTP/2 協定。
圖書目錄
第1部分 向HTTP/2靠攏
第1章 全球資訊網與HTTP....................................................................................................3
1.1 全球資訊網的原理.......................................................................................................3
1.1.1 網際網路與全球資訊網.......................................................................................4
1.1.2 打開網頁時會發生什麼...........................................................................5
1.2 什麼是HTTP.........................................................................................................9
1.3 HTTP的語法和歷史 ...........................................................................................16
1.3.1 HTTP/0.9.................................................................................................16
1.3.2 HTTP/1.0.................................................................................................17
1.3.3 HTTP/1.1.................................................................................................23
1.4 HTTPS簡介.........................................................................................................29
1.5 查看、傳送和接收HTTP訊息的工具...............................................................32
1.5.1 瀏覽器開發者工具.................................................................................32
1.5.2 傳送 HTTP 請求 .....................................................................................34
1.5.3 其他工具.................................................................................................35
總結..............................................................................................................................36
第2章 通向HTTP/2之路...............................................................................................37
2.1 HTTP/1.1和當前的全球資訊網 .................................................................................38
2.1.1 HTTP/1.1 根本的性能問題....................................................................40
2.1.2 HTTP/1.1 管道化....................................................................................42
2.1.3 網路性能瀑布流圖 .................................................................................43
2.2 解決HTTP/1.1性能問題的方案.........................................................................45
2.2.1 使用多個 HTTP 連線.............................................................................46
2.2.2 傳送更少的請求.....................................................................................49
2.2.3 HTTP/1 性能最佳化總結 ...........................................................................50
2.3 HTTP/1.1的其他問題 .........................................................................................50
2.4 實際案例.............................................................................................................51
2.4.1 示例網站 1: amazon.com .......................................................................52
2.4.2 示例網站 2 : imgur.com.........................................................................56
2.4.3 這個問題究竟有多嚴重 .........................................................................57
2.5 從HTTP/1.1到HTTP/2........................................................................................58
2.5.1 SPDY.......................................................................................................58
2.5.2 HTTP/2....................................................................................................61
2.6 HTTP/2對Web性能的影響.................................................................................62
2.6.1 展示 HTTP/2 能力的絕佳示例..............................................................62
2.6.2 對 HTTP/2 提升性能的期望 ..................................................................65
2.6.3 HTTP/1.1 的一些性能變通方法可能是反模式 ....................................70
總結 ..............................................................................................................................70
第3章 升級到HTTP/2...................................................................................................72
3.1 HTTP/2的支持 ....................................................................................................72
3.1.1 瀏覽器對 HTTP/2 的支持......................................................................73
3.1.2 伺服器對 HTTP/2 的支持......................................................................78
3.1.3 兼容不支持 HTTP/2 的情況..................................................................80
3.2 網站開啟HTTP/2的方法....................................................................................81
3.2.1 在 Web 伺服器上開啟 HTTP/2..............................................................81
3.2.2 反向代理實現 HTTP/2 ...........................................................................84
3.2.3 通過 CDN 實現 HTTP/2........................................................................87
3.2.4 小結.........................................................................................................89
3.3 常見問題.............................................................................................................89
總結 ..............................................................................................................................93
第2部分 使用HTTP/2
第4章 HTTP/2協定基礎...............................................................................................97
4.1 為什麼是HTTP/2而不是HTTP/1.2....................................................................97
4.1.1 使用二進制格式替換文本格式 .............................................................99
4.1.2 多路復用代替同步請求.......................................................................100
4.1.3 流的優先權和流量控制.......................................................................103
4.1.4 首部壓縮 ...............................................................................................104
4.1.5 服務端推送...........................................................................................105
4.2 如何創建一個HTTP/2連線 ..............................................................................105
4.2.1 使用 HTTPS 協商.................................................................................106
4.2.2 使用 HTTP upgrade 首部.....................................................................113
4.2.3 使用先驗知識 .......................................................................................116
4.2.4 HTTP AlternativeServices....................................................................117
4.2.5 HTTP/2 前奏訊息 .................................................................................117
4.3 HTTP/2幀..........................................................................................................119
4.3.1 查看 HTTP/2 幀....................................................................................119
4.3.2 HTTP/2 幀數據格式.............................................................................126
4.3.3 HTTP/2 訊息流示例.............................................................................128
4.3.4 其他幀 ...................................................................................................143
總結............................................................................................................................148
第5章 實現HTTP/2推送.............................................................................................149
5.1 什麼是HTTP/2服務端推送..............................................................................149
5.2 如何推送...........................................................................................................153
5.2.1 使用 HTTP link 首部推送....................................................................153
5.2.2 查看 HTTP/2 推送................................................................................156
5.2.3 使用 link 首部從下游系統推送 ...........................................................159
5.2.4 更早推送...............................................................................................162
5.2.5 使用其他方式推送 ...............................................................................168
5.3 HTTP/2推送在瀏覽器中如何運作..................................................................171
5.3.1 查看推送快取如何工作.......................................................................172
5.3.2 使用 RST_STREAM 拒絕推送...........................................................175
5.4 如何實現條件推送 ...........................................................................................176
5.4.1 在服務端跟蹤推送的資源...................................................................176
5.4.2 使用 HTTP 條件請求 ...........................................................................176
5.4.3 使用基於 cookie 的推送......................................................................177
5.4.4 使用快取摘要.......................................................................................178
5.5 推送什麼...........................................................................................................179
5.5.1 你能推送什麼.......................................................................................179
5.5.2 應該推送什麼 .......................................................................................180
5.5.3 自動化推送 ...........................................................................................181
5.6 HTTP/2推送常見問題 ......................................................................................182
5.7 HTTP/2推送對性能的影響 ..............................................................................184
5.8 對比推送和預載入...........................................................................................185
5.9 HTTP/2推送的其他套用場景..........................................................................188
總結 ............................................................................................................................190
第6章 HTTP/2最佳化....................................................................................................192
6.1 HTTP/2對Web開發者的影響 ...........................................................................192
6.2 一些HTTP/1.1最佳化方法是否成了反模式.......................................................194
6.2.1 HTTP/2 請求依然有開銷.....................................................................194
6.2.2 HTTP/2 不是沒有限制.........................................................................197
6.2.3 越大的資源壓縮越有效 .......................................................................199
6.2.4 頻寬限制和資源競爭 ...........................................................................201
6.2.5 域名分片...............................................................................................202
6.2.6 內聯資源...............................................................................................203
6.2.7 總結.......................................................................................................203
6.3 在HTTP/2下依然有效的性能最佳化技術..........................................................204
6.3.1 減少要傳輸的數據量 ...........................................................................204
6.3.2 使用快取防止重複傳送數據 ...............................................................211
6.3.3 Service Worker 可以大幅減少網路載入 .............................................215
6.3.4 不傳送不需要的內容...........................................................................216
6.3.5 HTTP 資源暗示 ....................................................................................217
6.3.6 減少最後 1 公里的延遲.......................................................................219
6.3.7 最佳化 HTTPS..........................................................................................219
6.3.8 和 HTTP 無關的性能最佳化技術 ...........................................................222
6.4 同時對HTTP/1.1和HTTP/2做最佳化..................................................................222
6.4.1 計算 HTTP/2 流量................................................................................223
6.4.2 在服務端檢測 HTTP/2 支持................................................................224
6.4.3 在客戶端檢測 HTTP/2 支持................................................................228
6.4.4 連線合併 ...............................................................................................228
6.4.5 還要為 HTTP/1.1 的用戶最佳化多久.....................................................230
總結............................................................................................................................231
第3部分 HTTP/2進階
第7章 高級HTTP/2概念.............................................................................................235
7.1 流狀態...............................................................................................................236
7.2 流量控制 ...........................................................................................................239
7.2.1 流量控制示例.......................................................................................240
7.2.2 在伺服器上設定流量控制 ...................................................................244
7.3 流優先權...........................................................................................................244
7.3.1 流依賴關係...........................................................................................245
7.3.2 流權重...................................................................................................248
7.3.3 為什麼優先權策略如此複雜 ...............................................................251
7.3.4 Web 伺服器和瀏覽器中的優先權策略 ...............................................252
7.4 HTTP/2一致性測試..........................................................................................255
7.4.1 服務端一致性測試...............................................................................255
7.4.2 客戶端一致性測試...............................................................................258
總結............................................................................................................................258
第8章 HPACK首部壓縮.............................................................................................259
8.1 為什麼需要首部壓縮.......................................................................................259
8.2 壓縮的運作方式 ...............................................................................................261
8.2.1 查表法 ...................................................................................................262
8.2.2 更高效的編碼技術...............................................................................263
8.2.3 Lookback( 反查 ) 壓縮.........................................................................264
8.3 HTTP正文壓縮.................................................................................................265
8.4 HTTP/2的HPACK首部壓縮.............................................................................267
8.4.1 HPACK 靜態表 .....................................................................................268
8.4.2 HPACK 動態表.....................................................................................269
8.4.3 HPACK 首部類型 .................................................................................269
8.4.4 Huffman 編碼表...................................................................................275
8.4.5 Huffman 編碼腳本 ...............................................................................276
8.4.6 為什麼 Huffman 編碼不總是最佳的..................................................278
8.5 HPACK壓縮實例..............................................................................................279
8.6 客戶端和服務端對HPACK的實現..................................................................285
8.7 HPACK的價值..................................................................................................287
總結 ............................................................................................................................287
第4部分 HTTP的未來
第9章 TCP、QUIC和HTTP/3....................................................................................291
9.1 TCP的低效率因素,以及HTTP ......................................................................292
9.1.1 創建 HTTP 連線的延遲.......................................................................293
9.1.2 TCP 擁塞控制對性能的影響...............................................................295
9.1.3 TCP 低效率因素對 HTTP/2 的影響 ...................................................303
9.1.4 最佳化 TCP ...............................................................................................307
9.1.5 TCP 和 HTTP 的未來...........................................................................313
9.2 QUIC.................................................................................................................313
9.2.1 QUIC 的性能優勢................................................................................315
9.2.2 QUIC 和網路技術棧 ...........................................................................316
9.2.3 什麼是 UDP,為什麼 QUIC 基於它 ..................................................317
9.2.4 標準化 QUIC........................................................................................320
9.2.5 HTTP/2 和 QUIC 的不同.....................................................................322
9.2.6 QUIC 的工具 ........................................................................................325
9.2.7 QUIC 實現 ............................................................................................327
9.2.8 你應該使用 QUIC 嗎...........................................................................327
總結............................................................................................................................328
第10章 HTTP將何去何從..........................................................................................329
10.1 關於HTTP/2的爭議,以及它沒有解決的問題............................................330
10.1.1 反對 SPDY 的觀點 .............................................................................330
10.1.2 隱私問題和 HTTP 中的狀態.............................................................332
10.1.3 HTTP 和加密......................................................................................337
10.1.4 傳輸協定的問題.................................................................................340
10.1.5 HTTP/2 太過於複雜 ...........................................................................344
10.1.6 HTTP/2 是一種權宜之計 ...................................................................345
10.2 HTTP/2的實際套用........................................................................................345
10.3 HTTP/2的未來版本,HTTP/3或者HTTP/4會帶來什麼 ..............................347
10.3.1 QUIC 是 HTTP/3 嗎...........................................................................347
10.3.2 更進一步改進 HTTP 二進制協定....................................................348
10.3.3 在傳輸層之上進一步最佳化 HTTP ......................................................348
10.3.4 什麼時候會需要新的 HTTP 版本 .....................................................351
10.3.5 如何引入未來版本的 HTTP..............................................................352
10.4 將HTTP當作一個更通用的傳輸協定...........................................................352
10.4.1 使用 HTTP 語義和訊息來傳遞非 Web 流量 ....................................353
10.4.2 使用 HTTP/2 二進制成幀層..............................................................354
10.4.3 使用 HTTP 啟動另一個協定.............................................................355
總結 ............................................................................................................................359
附錄A 將常見Web伺服器升級到HTTP/2...................................................................360
作者簡介
BARRY POLLARD 是一位專業軟體開發者,在開發、支持軟體和基礎架構方向擁有近 20 年的行業經驗。他對Web 技術、性能調優、安全以及技術實踐非常感興趣。
鄭維智,Akamai公司高級企業架構師,專注於公司的主要客戶及戰略合作夥伴。他也是Web性能最佳化和HTTP/2的布道者,為Akamai的產品開發團隊提供技術建議和客戶反饋。