logoalt Hacker News

gaigalastoday at 7:54 AM1 replyview on HN

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.


Replies

8cvor6j844qw_d6today at 2:22 PM

Hmm... sort of like an intermediate page?

That would explain a some of the design decisions. I had to do work on a old codebase and am studying it.

Thank you and the others too for the input.