HTTP 204 No Content
成功狀態碼表明請求成功,但客戶端不需要更新目前的頁面。204 回應預設是可被快取的,此類回應中會包含 ETag
標頭。
回傳 204
的常見情況是作為 PUT
請求的回應,更新一個資源且沒有更動目前顯示給使用者的頁面內容。若是有資源被建立,201
Created
則應該被回傳。而若頁面應該更新為新的頁面,則應使用 200
。
狀態
204 No Content
規範
Specification | Title |
---|---|
RFC 7231, section 6.3.5: 204 No Content | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
瀏覽器相容性
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
相容性事項
- 雖然此狀態碼意圖表示不具主體的回應,伺服器仍可能錯誤地在標頭後加入資料。通訊協定允許使用者代理更動此回應的處理方式 (關於規範的討論請參見此處)。這在持久連接中可以被觀察到,無效的主體可能會包含後續請求的不同回應 。
Apple Safari 拒收這些資料。Google Chrome 及 Microsoft Edge 在有效回應之前丟棄最多四個無效的位元組。Firefox 容許在有效回應之前超過1KB 的無效資料。