From 543591042ea5638a8a42d49d2f1db835fbf2724d Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 9 Jun 2022 15:56:00 +0200 Subject: [PATCH] gateway: switch only-if-cached miss to 412 Rationale: https://github.com/ipfs/go-ipfs/issues/8783#issuecomment-1137921326 --- http-gateways/PATH_GATEWAY.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/http-gateways/PATH_GATEWAY.md b/http-gateways/PATH_GATEWAY.md index 221f36f6..48e0710b 100644 --- a/http-gateways/PATH_GATEWAY.md +++ b/http-gateways/PATH_GATEWAY.md @@ -136,9 +136,13 @@ gateway already has the data (e.g. in local datastore) and can return it immediately. If data is not cached locally, and the response requires an expensive remote -fetch, a 504 (Gateway Timeout) status code should be returned. +fetch, a 412 Precondition Failed HTTP status code should be returned by the +gateway without any payload or specific HTTP headers. + +The code 412 is used instead of 504 because only-if-cached is handled by the +gateway itself, moving the error to client error range and avoiding confusing +server errors in places like the browser console. -See [RFC7234#only-if-cached](https://datatracker.ietf.org/doc/html/rfc7234#section-5.2.1.7) ### `Accept` (request header)