0

There is a similar looking question asked at : How can I shorten the URL query paramters?
But here the query parameter is single and its value is comma separated list of long Ids.

Eg. http://example.com/page?q='111100000123,111100000234,11134423213,238418249,823481293,841298472384,89234798124,981248923,24982134983'

Encode this value to something like

htp://example.com/page?q='cdw,erw,ere...'

or

htp://example.com/page?q=asfjeoren

and then decode it back at server side to original value.

Community
  • 1
  • 1
Vineet Singla
  • 1,609
  • 2
  • 20
  • 34

1 Answers1

0

Assuming you want the encoded versions of your ids to use alphanumeric characters, and if your ids are all 12 digits (or less) then you would need up to 6 encoded characters per id - you won't get it down to 3 characters as in your example, there simply aren't enough combinations of alphanumeric characters to be able to uniquely represent each id.

I would question if it is actually worth doing what you propose - how many ids are going to be in your urls? Have you proved that the long urls actually cause a problem or are you pre-optimising?

codebox
  • 19,927
  • 9
  • 63
  • 81
  • My IDs are upto 19 digit long, How many IDs no limit , but 90% around 50. Dont want to send long URls to server – Vineet Singla Aug 11 '15 at 11:35
  • 1
    Ok, 19 digits means you would need 11 alphanumeric characters. Why don't you want to send long urls to the server? Is it just because 'it feels wrong' or have you demonstrated that it causes some kind of problem? – codebox Aug 11 '15 at 11:58
  • How did you come up with 11 alphanumeric characters required for 19 digits? To represent the highest value 19 digits can store in base 10, I think 12 digits are needed in base 36? – ricky116 Aug 11 '15 at 13:41
  • Scratch that - checked more reliable sources than a back-of-hand type approach. *13* alphanumeric digits would be required for 19 base-ten digits – ricky116 Aug 11 '15 at 13:51
  • 1
    @ricky116 I was assuming he would use both upper/lower case letters - effectively base 62 – codebox Aug 11 '15 at 14:15