2

Suppose my HTTP server code implements the GET method on /example, replying with either JSON or HTML depending on the Accept header and setting Vary: Accept. The same data are also available without content negotiation at /example.json and /example.html, respectively.

Would I be using the canonical link relation correctly if I set Link: </example.json>;rel=canonical on /example when serving JSON, but Link: </example.html>;rel=canonical when serving HTML?

(A similar scenario could be constructed for entirely user-facing pages when using Accept-Language to choose the default language, provided that I don’t want to pay the cost of a redirect.)

Community
  • 1
  • 1
Alex Shpilkin
  • 776
  • 7
  • 17
  • Related: the Content-Location header ([MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Location), [SO](https://stackoverflow.com/a/448328)), which for `/example` with `Accept: application/json` would point to `/example.json`. – Alex Shpilkin Feb 23 '19 at 22:29

0 Answers0