如何告诉 HTTP 客户端在哪里可以找到文件的最新版本?

发布于 2025-01-10 11:21:00 字数 1131 浏览 6 评论 0原文

我正在为数据集设计一个 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"

类似问题:

在撰写本文时,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 versionHint: 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:

At the time of writing there is no suitable entry in this list on MDN

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔日梦未散 2025-01-17 11:21:00

我可以/应该使用比“latest”更好的 rel 参数值吗?

IANA 链接关系注册表是一个不错的查找地点;在那里,您会找到已注册的链接关系、非权威摘要以及权威参考文献的链接。

示例

latest-version

Points to a resource containing the latest (e.g., current) version of the context.

https://www.iana.org/go/rfc5829

RFC 5829 是Web 资源之间简单版本导航的链接关系类型,以及它当然包括 最新版本

is there a better value for the rel parameter than "latest" that I could/should use?

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

latest-version

Points to a resource containing the latest (e.g., current) version of the context.

https://www.iana.org/go/rfc5829

RFC 5829 is Link Relation Types for Simple Version Navigation between Web Resources, and it of course includes a definition for latest-version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文