Frage

RESTful Web Services encourages the use of HTTP 303 to redirect clients to the canonical representation of a resource.

According to the book, HTTP 302 is was replaced by 303 ("See Other") and 307 ("Temporary redirect"). There is also HTTP 301 ("Permanent redirect"). Clients may cache HTTP 301 and 307 but not 303.

In light of this, which status code(s) are appropriate canonicalization? Why does the book advocate the use of HTTP 303 over say 307? The latter, after all, is cacheable.

War es hilfreich?

Lösung

RESTful Web Services seems to favor temporary redirects for canonicalization. They give an example of search queries as non-canonical URIs that redirect to search results. In that context, it makes a lot of sense to treat canonicalization as a temporary redirect because we expect search results to change over time.

In case someone is looking for cacheable permanent redirects take a look at the draft standard for 308 Permanent Redirect. This allows you to pick between temporary vs permanent redirection, cacheable vs non-cacheable. Use whatever makes sense for your use-case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top