Mobile Development Network Traffic streamlining strategy and network traffic Strategy

Source: Internet
Author: User
Tags webp

Mobile Development Network Traffic streamlining strategy and network traffic Strategy

As a mobile developer, I have also worked on many projects over the past few years. Today I am writing a simple article on network traffic reduction. I hope this article will help all mobile developers, and the service developers of interfaces are helpful.


Why is it simplified? (Why)

1. Save User traffic.

Because the user's traffic may be paid, saving the user's traffic is one of the principles that every mobile developer should keep in mind.

2. Improve Network data loading speed.

The traffic is reduced, and the interface's data acquisition speed is improved, and some page loading speeds of applications can be improved. I think everyone can understand this.

3. reduce the pressure on the server.

Using the optimized interface to reduce the amount of data, you can improve the server utilization and reduce the server concurrency pressure. A single request connection occupies 2 s and 20 ms, which is very different for the server.


How to streamline it? (How)

1. simplified definition of Network Interface APIs

(A) interface definition:

In the interface design phase, streamline the volume of non-content fields, such as "productionDescription": "Product Introduction xxx" can be simplified to "pdDes": "Product Introduction xxx "; deleting a field irrelevant to the content has found that many interfaces return fields such as "name": null. In fact, this data can be completely filtered out.

(B) Request optimization:

Some interfaces that return less frequent data changes can be considered to add version numbers to mark the status. New data is returned only when the interface sends a change; otherwise, no changes are returned and the client uses the cache; or request the corresponding data interface only when the status is detected to change. Otherwise, not processing is also a good way to reduce server requests.

2. Use compression technology

(A) For text data, enabling GZip for data compression is a good choice. For text data compression up to 80%, I previously had an interface to return KB of data, after compression is enabled, it is only 80 KB, and the effect is obvious. You can also use compression when submitting data.

(B) For image data, using Google's WebP format will greatly reduce the image size. After testing, in the same definition, WebP format is about 30-40% of the size of JPG format, for example, a k jpg image is transmitted in WebP format as long as 90 K. It should be noted that the WebP format is not supported by some platforms and browsers by default, and may need to be supported by the corresponding libraries, but it is worthwhile to save traffic.

3. Make full use of Cache

The principle of using the cache is believed to be known. By storing data locally, you can read the same data from the local server instead of requesting it.

But there is a big guy in the cache: images. If you have a large number of images in your application, you must study the image Cache Usage. Generally, developers can follow the cache policy to request images themselves. However, some special pages on the client are easy to ignore. For example, in the webview of the client, developers need to combine webview with your cache policy by some means, achieve perfect image cache usage. For the combination of image cache and WebView in iOS, I will write a detailed article later.


This article is generic in general and provides some key points, hoping to inspire developers.


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.