Home  >  Q&A  >  body text

android - hybrid app如何进行打包下载前端资源?

背景

由于手上的Android app需要改版,用户流量越发增加,H5活动页面、展示页面也陆续地增加。所以打算基于native实现缓存方案加速。

架构

我们的架构是hybrid app,只有首页是native实现的,下面的几个条目作为H5的入口。
(为避免广告嫌疑,已经屏蔽相关字眼)

解决方案

上网查了一下hybrid app的H5加速方案,详见:http://trock.lofter.com/post/117023_e8e175

方案一:使用manifest,但是坑比较多,而且也不是最好的方案,一个文件改,所有都要更新。
方案二:打包下载前端资源,Android本地的解压。然后native和H5用spdy协议请求页面。Android可以实现增量更新。

我的疑惑

关于方案二是具体实现方法,我在网上搜索不到,而且很疑惑:
1.前端资源打包,是在服务器上发生的吗?
2.客户端如果知道有更新,对比md5,但不是说下载打包好变成一个zip包吗?那它怎么样去识别个边页面的更新?

或者我的理解完全错了?
有经验的同学请指教,谢谢!

怪我咯怪我咯2719 days ago423

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:28:08

    I have no experience in developing hybrid APPs, but there are many functions that I will choose to present in the form of WebView + pages.
    So the purpose of the question is to reduce access traffic. WebView itself has a caching mechanism. I don’t know why you need to download pictures and other related resources first. If the package is compared against resources, then a picture has been modified. Do the resources of the entire page need to be downloaded again?

    Because my side is in the form of local html pages and network images, so every time I need to update only the local html page, the images or CSS and js are still on the back end. WebView will perform appropriate caching. Since I don’t know the development form of the subject’s hybrid application, it is not easy to publish.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 17:28:08

    A CDN does not solve the problem. .

    reply
    0
  • PHPz

    PHPz2017-04-17 17:28:08

    I am responsible for front-end development.

    I asked my client colleagues for advice and came up with two solutions:
    ①The backend packages pages that are not frequently updated and the client decompresses them;
    ②For frequently updated pages, the backend sends a list, which contains the name of the file, Version number, md5. The client downloads this list, performs diff operations, and downloads, replaces, and deletes files according to certain rules.

    I consulted my backend colleagues and got the following information:
    The main business of this app is on the backend. The current traffic level, even after the revision, is still far from 1000qps at 5 times, so the current resources do not run CDN That's ok too. Front-end performance optimization is not very necessary at this stage, and the reconstruction of file directories and code is more important.

    Comprehensive solution:
    At this stage, there is no need to think too much about performance optimization, so the solution obtained from client colleagues may not be implemented until later. @zzxxasp The solution mentioned by the classmate is to use webview caching which is enough. It can also be combined with @TIGERB’s CDN solution.

    reply
    0
  • Cancelreply