AngularJS压缩$ http发布数据 [英] AngularJS compress $http post data

查看:610
本文介绍了AngularJS压缩$ http发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个需要发送大量数据到以php写的服务器的Ionic应用程序。我正在寻找一种方式来压缩数据我发布,加快我的应用程序。我不知道什么是最好的方法,我尝试 LZString ,但compressToEncodedURIComponent返回值大小是对我的需求太大,我然后尝试使用 pako ,但我仍然不满意的压缩率。哪个是压缩数据我发布到服务器的最好的方法?我应该单独压缩它(我提到的其中一个库)还是有一种方法让Angular $ http服务处理压缩?

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?

推荐答案

Angular没有压缩实用程序。

Angular has no compression utilities.

如果你真的需要压缩,那么你必须找到一个JavaScript库,这样做,我不知道,但此问题

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.

由于压缩本身可能需要一些时间(并不总是产生很好的结果),或许是另一种选择是使用您自己的代码使数据尽可能精简,然后只是有一个很好的等待UX - 让用户了解进度,让他们做的东西,而它在后台上传。大多数移动用户希望大数据传输需要一段时间。

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.

这篇关于AngularJS压缩$ http发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆