logoalt Hacker News

Zambytetoday at 7:27 AM1 replyview on HN

What if the stuff you want to see can't be encoded in a URL?


Replies

gaigalastoday at 7:54 AM

I'm assuming the case here is lots of query params. Stuff like `?foo=bar&lorem=ipsum...`.

Most likely, you would benefit from making a cirurgical mini-resource on the server.

Introduce `/report/{id}`, and make it into a POST.

The user POSTs to `/report`, and the answer is 201 (Created) or 202 (Accepted), with a `Location: /report/123` (generated short id). The thing you changed on the server, is that now that long list have a short id. Just that.

Then, the user `GET /report/123` (auto redirect). It all happens within the same socket (keep-alive) and it has almost zero overhead (one refresh without this probably has thousands of times more overhead than the redirect).

By doing that, it seems that you are wasting stuff, but you're not.

Now the user doesn't have to transfer huge amounts of query data when GETing the results again, cache layers will have an easier time, and you can even use that mini-resource as a shortcut to solve things like racing conditions (two users doing the same humongous query at the same time).

Realistically, unless you're some query-by-image type of thing (trying to search images that match an existing one), you'll never actually have to face URL limits. If you are one of those cases, then you probably already have other architectural constraints that would justify introducing the extra intermediate resource.

show 1 reply