Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS compress $http post data

I'm creating an Ionic app that needs to send big amounts of data to a server written in php. I'm looking for a way to compress the data I post to speed up my app. I'm not sure of what's the best approach, I tried LZString but the compressToEncodedURIComponent return value size is too big for my needs, I then tried using pako but I still wasn't satisfied with the compression rate. Which is the best way to compress the data I post to the server? Should I compress it separately(with one of the libraries I mentioned) or is there a way to let the Angular $http service handle the compression?

like image 337
Daniele Sassoli Avatar asked Nov 10 '22 06:11

Daniele Sassoli


1 Answers

Angular has no compression utilities.

If you really need to compress then you will have to find a JavaScript library to do so, which I know nothing about, but this question and this question would be good places to start.

Given that compression can take some time itself (and doesn't always yield great results), perhaps another alternative is to make the data as lean as possible using your own code, then just have a good 'waiting' UX - keep the user informed about the progress and let them do stuff while it uploads in the background. Most mobile users will expect large data transfers to take a while anyway.

like image 199
Ed_ Avatar answered Nov 14 '22 21:11

Ed_