# 與HTTP/2的比較

HTTP/3 是為 QUIC 設計的，QUIC 是一種能自行處理資料串流的傳輸層協定。

HTTP/2 是為 TCP 設計的，因此資料串流在 HTTP 層處理。

## 相似處 ( Similarities )

這兩種協定為客戶端提供了幾個幾乎相同的功能集。

* 兩者都提供伺服器端推送
* 兩種協定都具有標頭壓縮，並且 QPACK 和 HPACK 在設計上相似
* 兩種協定都在單個連接上提供串流多路復用。

## 不同處 ( Differences )

區別主要在細節上，並且歸因於 HTTP/3 對 QUIC 的使用:

* 得益於 QUIC 的 0-RTT 握手，HTTP/3 可以提供更好的 early data 支援，而 TCP Fast Open 和 TLS 通常只能傳輸更少的數據，且經常存在問題。
* 得益於 QUIC，HTTP/3 的握手速度比 TCP+TLS 快得多。
* HTTP/3 不存在明文的不安全版本。儘管在網際網路上很少見，HTTP/2 還是可以不配合 HTTPS 來實現和使用。
* 通過 ALPN 拓展，HTTP/2 可以直接在 TLS 握手時進行協商。 HTTP/3 基於 QUIC，所以需要憑藉回應中的 `Alt-Svc:` 標頭來向客戶端宣告。
* HTTP/3 不提供優先級控制。 計劃用於 HTTP/3 的 HTTP/2 優先級控制方法被認為過於復雜或根本無法適用，目前正在努力創建一種更簡單的機制。 當前計劃的更簡單的機制是向後移植到 HTTP/2，並利用 HTTP/2 的擴展規範優先級控制。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://http3-explained.haxx.se/zh-tw/h3/h3-h2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
