Search code examples
resthttp-headersversionpermalinkssemantics

How to tell an HTTP client where to find the latest version of a file?


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:

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


Solution

  • 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.