1

I have a long string (it's a base64 data) with 2 000 000 characters.

I need to send this string with ajax to a php script, but the execution time is very long.

After test, if i reduce the number of character, my ajax request is speeder.

So, how can i reduce, compress or don't know... my string with javascript, and decompress this string with php ?

I have test lz-string, but it's the same, the result is a big array and it's not really speeder.

Do you have any solutions for me ? Maybe replace the longer substring, wich is repeat x times by "$", and inverse replace with php ? thanks !

Edit : my ajax call

$.ajax({
            type:"POST",
            url: "/webcam/",
            data: {image_gif:gif},
            success: function () {
                parent.$.fancybox.close();
            }
        });

gif is a string with 2 000 000 of characters, or an array of chunk with 500 000 characters each.

Clément Andraud
  • 9,103
  • 25
  • 80
  • 158
  • I have no code to show...i'm trying to send a base64data, it's a long string... with post ;) – Clément Andraud Feb 27 '14 at 13:41
  • Yep, it's a gif. I edit with the ajax call – Clément Andraud Feb 27 '14 at 13:43
  • You're sending about 2MB, which is a lot(-ish), I doubt you can compress it much. If that could be done, every site would love to see that code, because that would decrease uploadtime and bandwidth dramatically. – Martijn Feb 27 '14 at 13:44
  • Maybe not compress the gif, but a way to reduce the size of the string by a magic way, and retrieve the real string after with php – Clément Andraud Feb 27 '14 at 13:47
  • possible duplicate of [Lossless compression method to shorten string before base64 encoding to make it shorter?](http://stackoverflow.com/questions/4144704/lossless-compression-method-to-shorten-string-before-base64-encoding-to-make-it) – Martijn Feb 27 '14 at 13:58
  • You can use gzip technique to compress your data before sending to server. – Akansh Sep 13 '17 at 20:25

0 Answers0