What I am facing:
I am building a search application that involves several search parameters and I would like to be able to bookmark the URL for later usage.
I imagine the solution would something like the following:
- User views the page, picks search parameters they want to filter.
- Browser do a POST request with the parameters.
- The application compiles/aggregates the parameters into one [A].
- The user can copy the URL with [A] appended and repeat the same search in the future.
To give a bit vision, both request below should be equal:
Original request:
POST /search (with POSTed parameters key1=asd and key2=10)
Subsequent/bookmarkable request:
GET /search?params=ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890
params
should be reversible (and probably validated, but not crucial) to the original parameters.
My question is: what would be the best scheme to compile the parameters into one parameter?
What I have thought so far:
I am thinking about using key-value dictionary, comma separated, Base64 encoded; but I'm not sure how long the encoded string would be (also keep in mind URL length limitation). What I'm probably looking for is probably a reversible compression. Any gotcha over this approach is welcome.