如何告诉 HTTP 客户端在哪里可以找到文件的最新版本?
我正在为数据集设计一个 HTTP API。我想要指向数据集中文件的每个历史版本的永久链接以及重定向到最新版本的 URL。我想添加一个标头,使客户端能够发现给定特定版本 URL 的最新 URL:
GET /example/v1
200 OK
Link: </example/latest>; rel="latest"
GET /example/v2
200 OK
Link: </example/latest>; rel="latest"
GET /example/latest
303 See Other
Location: /example/v2
我想知道:rel 参数是否有比“最新”更好的值/应该使用?注意:我知道我应该添加 Link: ; rel="canonical"
,但 rel="canonical"
捕获的语义与我想要描述的不同。
rel="latest" | rel="canonical" |
---|---|
这是您可以找到最新版本的地方 | 提示:如果您是搜索引擎,这是我希望您在对一组相似结果进行分组时使用的页面 |
这并非不可行可能想要提供链接:; rel="canonical"
甚至链接:; rel="canonical"
类似问题:
- rel=canonical 元标记可以指向 301 重定向 URL 吗? :Google 将如何处理特定场景?
- 我的问题:如何最好地传达我想要的语义?
在撰写本文时,MDN 上的此列表中没有合适的条目< /a>
I am designing an HTTP API for a dataset. I want permanent links to each historical version of a file in the dataset as well as a URL that redirects to the latest version. I want to add a header to enable clients to discover the latest URL given the URL for a specific version:
GET /example/v1
200 OK
Link: </example/latest>; rel="latest"
GET /example/v2
200 OK
Link: </example/latest>; rel="latest"
GET /example/latest
303 See Other
Location: /example/v2
I want to know: is there a better value for the rel parameter than "latest" that I could/should use? Note: I am aware that I should add Link: </example/latest>; rel="canonical"
, but rel="canonical"
captures a different semantic than I want to describe.
rel="latest" | rel="canonical" |
---|---|
This is where you can find the latest version | Hint: if you are a search engine, this is the page I want you to use when grouping a set of similar results |
It is not infeasible that I may want to serve Link: </example/v2>; rel="canonical"
or even Link: </example/v1>; rel="canonical"
Similar questions:
- Can a rel=canonical meta tag point to a 301 redirect URL?: How will Google handle a given scenario?
- My question: How to best communicate the semantics I want?
At the time of writing there is no suitable entry in this list on MDN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IANA 链接关系注册表是一个不错的查找地点;在那里,您会找到已注册的链接关系、非权威摘要以及权威参考文献的链接。
示例
RFC 5829 是Web 资源之间简单版本导航的链接关系类型,以及它当然包括 最新版本。
A good place to look is the IANA Link Relations registry; there, you will find registered link relations, non-authoritative summaries, and a link to the authoritative reference.
Example
RFC 5829 is Link Relation Types for Simple Version Navigation between Web Resources, and it of course includes a definition for latest-version.