Mobile development network traffic streamlining strategy

Source: Internet
Author: User
Tags webp

As a mobile developer, I've done a lot of projects in the past few years, and I'm writing a shallow, web-saving article today, and hopefully this article will help all mobile developers, as well as the interface's server developers.


Why Streamline? (why)

1. Save users ' traffic.

Because the user's traffic may be charged, saving the user traffic is one of the principles that every mobile developer should remember firmly

2. Increase the speed of network data loading.

Traffic is streamlined, interface to get data speed will be improved, the application of some page loading speed can be improved, I think everyone can understand

3. Reduce server pressure.

By optimizing the interface, reducing the amount of data, can improve the utilization of the server, reduce the concurrency of the server pressure, a single request connection occupies 2S and occupy 20ms is very different for the server


How to streamline? (how)

1. Network interface API Definition Refinement

(a) Interface definition:

In the design phase of the interface, the volume of non-content fields, such as "productiondescription": "Product introduction XXX" can be reduced to "pddes": "Product introduction xxx"; Delete Content-independent fields and now find that there are a lot of interfaces that return similar "name": Null such a field, in fact, this data can be completely filtered out.

(b) Request for optimization:

There are some interfaces to return data changes less frequently, you can consider adding a version number for the status flag, only when the interface sends changes to return the new data, or directly return unchanged to let the client use the cache, or to request the corresponding data interface when the state changes are detected. Otherwise, it is a good way to reduce requests to the server.

2. Using compression technology

(a) For text data, gzip-enabled data compression is a good choice, for text data compression can reach 80%, the author before an interface to return 300K of data, open compression only 80k, the effect is obvious. Compression processing can also be used when submitting data.

(b) For image data, the use of Google's WEBP format will greatly reduce the size of the image, after testing, the same definition, the WEBP format is the size of the JPG format 30-40% around, for example, 300K jpg format picture, in the WEBP format to transmit about as long as 90K. It is important to note that the WEBP format is not supported by default on some platforms and browsers and may require a library to support it, but it is worthwhile to save traffic.

3. Make the most of the cache

The principle of the use of the cache I believe we all know that through the previous storage of data to the local, when needed, through judgment, no longer request the same data from the server, directly read from the local use.

But there's a big guy in the cache: Pictures. If you have more pictures in your application, be sure to study the image of the cache use, the general developers themselves request pictures, can be done according to the cache strategy. However, there are some special pages in the client is easy to ignore, such as the WebView in the client's diagram, it is necessary to developers through a certain means, the WebView and your cache strategy to achieve the perfect image cache use. About the combination of image caching and WebView under iOS, a detailed article will be written later.


This article is generally more general, point out some key points, hope to be able to inspire developers.


Mobile development network traffic streamlining strategy

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.