6

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?

2

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank's, in the end I'll probably go with the second option, I tried to avoid it, but it looks like I can't.
1

If you use bower type bower install pako

Add <script src="bower_components/pako/dist/pako.min.js"></script> in your index.html

Use pako.gzip(JSON.stringify(data)) to compress.

The data is the json which you want to compress

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.