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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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.