# 使用Alt-svc進行引導

替代服務（ alternative service, Alt-svc: ）標頭和它相對應的 `ALT-SVC` HTTP/2 frame 並不是特別為 QUIC 和 HTTP/3 所設計的。 它是為了讓伺服器端能告訴客戶端 *"看，我在這個主機的這個端口用此協定提供相同的服務"* 。 詳見[RFC 7838](https://tools.ietf.org/html/rfc7838)。

收到這樣的 Alt-svc 回應後，如果客戶端支援並希望使用其他協定，則它將在後台使用指定的協定與主機進行並行連接，並且連接成功。 如果是這樣，它將切換到該協定，而不是使用第一個連接。

如果第一個連接使用 HTTP/2 或 HTTP/1，則伺服器端可以告訴客戶端可以通過 HTTP/3 重新連接。 它可以用於同一主機或是不同但提供相同服務的主機。

Alt-svc 回應中有一個到期計時器，讓客戶端可以在指定的時間內使用建議的替代協定後將後續連接和請求直接發送給替代主機。

## 範例

一個帶有 `Alt-Svc:` 標頭的 HTTP 伺服器回應：

```
Alt-Svc: h3=":50781"
```

這指出了同一名稱的主機在 UDP 端口50781能提供 HTTP/3 服務。

客戶端可以嘗試與該端口建立 QUIC 連接。如果成功，後續將通過該連接繼續通訊，代替一開始初始的 HTTP 版本。


---

# 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-altsvc.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.
