2

Possible Duplicate:
How to compress/decompress a long query string in PHP?

I have a huge amount of data inside my subquerystring for tracking needs.

I loose a lot of my data because of this too large url missinterpreted by clients or search engine or brower capability.

To avoid this problematics, I've decided to compress my querystrings into a smaller one. I've looked into the direction of xor, huffman, lzw & gzdeflate compression algorithm but I'm not satisfied for my url needs (I need to url encode after that...).

Questions :

  • Do you know any other algorythm which can fullfill my needs ?
  • Do you know which compression technics is the most efficient ?

More details:

  • No Post/Session method possible.
  • Every alphanumeric char can be inside the query string.
  • I have around 30 parameters to compress
Community
  • 1
  • 1
Dark
  • 505
  • 4
  • 12
  • 2
    Why so much in the querystring? If you're passing that much data, you should be using POST – Mark Baker Oct 19 '12 at 13:10
  • 1
    How large?, can you show an example. – Lawrence Cherone Oct 19 '12 at 13:11
  • @Mark Baker : It's affiliate url, so... no post. – Dark Oct 19 '12 at 13:12
  • @Lawrence Cherone : minimum -> 1k, maximum -> 5k of char – Dark Oct 19 '12 at 13:13
  • 1
    @Dark - have a look at [Maximum length of a URL](http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url) – ghoti Oct 19 '12 at 13:13
  • @ghoti : I know, that's why I need to compress my data ;) – Dark Oct 19 '12 at 13:16
  • 1
    Take a look at this chart of [compression rates for various algorithms](http://www.maximumcompression.com/data/text.php). Even with 80% compression you would still be flirting with the 2000 character limit that @ghoti mentioned. Query strings are not the right method for what you're trying to do. – james_t Oct 19 '12 at 13:17
  • @deceze - great post! How on earth do you remember something like that from so long ago?! I barely remember answers I wrote a month ago. – ghoti Oct 19 '12 at 13:28
  • @deceze https://www.google.co.uk/search?q=php+large+querystring+compression&sugexp=chrome,mod=18&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=php+Large+querystring+compression&oq=php+Large+querystring+compression&gs_l=serp.3...8592.8592.0.9058.1.1.0.0.0.0.73.73.1.1.0.les%3B..0.0...1c.2.B8qMS4hUxgo&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=973a42b6a2364274&bpcl=35466521&biw=1235&bih=1052 – Prisoner Oct 19 '12 at 13:32
  • 3
    @ghoti The truth is, I am an elephant with appropriately awesome memory. I dictate to a small Indian boy who types what I say on a keyboard. – deceze Oct 19 '12 at 13:32
  • 1
    Do you have an example of the kind of data you are sending? i.e. is one long text variable, or lots of smaller vars, arrays, encoded characters... and so on – Pebbl Oct 19 '12 at 13:35
  • All the char on your keyword can be inside it. Around 30 parameters. – Dark Oct 19 '12 at 13:38
  • 1
    Ok - I don't think you get what I meant... obviously any character can appear in the URL. A way to minimise large urls is to do away with the extra clutter certain constructions can add, like [] brackets or characters that have to be encoded *(each encoded character can add an extra 2+ characters)* -- similar to rison's approach (http://mjtemplate.org/examples/rison.html) - however you aren't encoding another structure inside a url so it's slightly different. – Pebbl Oct 19 '12 at 13:43
  • When you aren't satisfied with xor, huffman etc.pp why don't you use an url shortener? – Micromega Oct 19 '12 at 14:02
  • It won't change the problem. "I loose a lot of my data because of this too large url missinterpreted by clients or search engine or brower capability.". At the end with shortening system it finished with a 301 & the same crash with the browser. – Dark Oct 19 '12 at 14:11

0 Answers0