News for hackers. Stuff that matters.
Re:Use links not keys to represent relationships in APIs by jayd16 on Sunday May 12, 2019 @04:21AM (#19890797)
>(of course, the server must continue to honor all previously-issued URLs).

Why is this true for non-user facing urls? Seems like an argument could be made that you only need to support the urls for as long as the response was cacheable.

Re:Use links not keys to represent relationships in APIs by emn13 on Sunday May 12, 2019 @05:29AM (#19890958)
And the problem isn't really limited to links in the response; the same goes for computed links based on keys too.

In fact, links in responses are probably easier to update, because waiting for client software to upgrade can take a long time - but waiting for old versions to fall out of caches or at least dwindle to a small enough number is likely a much shorter wait.

Furthermore, when your clients are composing links based on keys, there's no good way for the server to tell a client that the uri has changed - the composition is in the client, and the key (presumably) hasn't changed, so the thing the server would want to update is out of conventional reach.

But with uri's there's at least a conventional solution - redirects. That's not going to be an ideal solution; but as a way of limiting transition pain it might have a place.

All in all, I think links are likely less painful to use than keys when it comes to uri routing changes. (But really, try to avoid changing uri's in the first place, because whatever you do it's likely going to be painful somewhere).

Re:Use links not keys to represent relationships in APIs by barrkel on Sunday May 12, 2019 @05:31AM (#19890962)
It's an API. The client isn't likely to be a browser. If it's integrating with another system, those links may have quite a long life.
Re:Use links not keys to represent relationships in APIs by randallsquared on Sunday May 12, 2019 @09:14AM (#19891663)
Caching behavior is not only about browsers.
Re:Use links not keys to represent relationships in APIs by barrkel on Sunday May 12, 2019 @09:49AM (#19891872)
For sure, but for most people using APIs to integrate with systems, caching is an unwanted middle way between always fresh and stored persistent, where local storage is the "cache", except it isn't invalidated using HTTP logic.
Re:Use links not keys to represent relationships in APIs by jayd16 on Sunday May 12, 2019 @06:21PM (#19894955)
>except it isn't invalidated using HTTP logic.

You should be doing this. It helps a lot, actually.

Re:Use links not keys to represent relationships in APIs by mpnally on Monday May 13, 2019 @11:14AM (#19900076)
Cache timeout limits generally apply to the data retrieved for a URL, not the URL. If you know that your clients will never "bookmark" or in any way store URLs, then you can change them. The same rule applies for all identifiers, not just URLs