preface

When it comes to APP optimization, we can also optimize our APP from many aspects, such as package size, page fluency, memory usage, data cache, network data security, etc. There are many things to be done for each point of expansion. I also wrote a blog about APP performance optimization before, as follows:

👉 iOS- Those Things about Performance Tuning

In the mobile APP network optimization is also a very important point of APP performance optimization, and 99.99% of apps will be accompanied by network interaction; Here, I will make a detailed summary of APP network optimization and network security, mainly from the aspects of traffic, quality and security. The structure points are as follows:

Traffic consumption

Let me first tell you something I have experienced. I used to develop an APP in a company. There was a customer service feedback from an old man in Shanghai who called me to scold me. Later, the company also took the initiative to help people bear this part of the traffic fee, the key is that 15 years of traffic fee is still very high, this APP is not written by me, of course, is android’s partner!

Detection flow consumption

Believe that everyone in the development of the APP will certainly do some buried report and log function, we can also do the monitoring of network request also, we can detect the flow of users over a period of time consumption, the calculation flow of mean and peak, etc., and report to flow interface, these we inside the log or buried point system can record, and then on to the server, Then carry on the data analysis, find out the insufficiency of the flow consumption.

Data cache

Speaking of caching, this is also a very big point, and I can expand on it if I have time. I also talk a lot about caching in my blog. One of the most important benefits of caching is that it improves page loading speed and improves user experience. However, caching can also save traffic consumption for users. The cache of APP data is nothing more than the cache of the list interface and the cache of the WebView. I have also written about the cache of the WebView separately as follows:

👉 ios-WkWebView Cache and Ensure Real-time

👉 ios-UIWebView Cache and Ensure Real-time performance

We can also do resource pack delivery preload and so on, here is not expanded!

Data compression

About data compression, here mainly want to talk about the resource file data compression, mainly in the network upload and network download;

1. Data upload for example, when uploading picture data, do we need the original hd image? Now that the camera has high pixels, can we compress the picture or video and then upload it?

2. Data download download is currently the biggest part of APP, generally APP is the request to download more data; When we load resources, we can choose to load compressed resources, such as wechat moments, we can load thumbnails when we click to view the big picture, and then we can load the original big picture.

Interaction frequency

If the data interaction is frequent, the user’s traffic will be consumed, and the user experience is not good. Another very important reason is that frequent network requests will also consume the battery of the mobile phone. So we can merge some network requests that can be merged, such as log reporting.

Request to release

In APP development process, it is commonly a access to the page for web requests, and then wait for the end of loading data, such as network, however, has pleaded for more slowly (could be data quantity is big, it is possible that the network status is bad), users don’t want to, such as direct return page is destroyed, but the majority of our network request is a single, But the network request is still in the request, here the data, performance, memory, power issues came out, so we in the packaging of the network request to destroy the page on the cancellation of the network request scenario into account!

Network quality

Request to speed

The speed of network requests is a very important factor affecting the user experience, so the server should also consider improving the interaction speed of the API. For this purpose, we can optimize the interaction speed through the following schemes:

A. Domain name consolidation reduces the number of DNS calls and reduces the risk of DNS hijacking;

B. IP direct connection, remove the DNS resolution step;

C. API cache, such as Redis cache;

D. Compress and upload data resources.

Request the quality

Monitor the quality and speed of network requests, record logs for reporting, and monitor complete network request links.

Server pressure

API design should also take into account the pressure of API and server, to prevent interface failure due to too much pressure, thus affecting the user experience;

The data processing

When the server provides data to the APP end, avoid data processing or calculation on the APP end. Compared with the limited memory resources and computing resources of the APP, do not consume and waste APP resources excessively. For example, the user information of my previous company contains the age of the user, but the server provides the birthday timestamp instead of the direct age data, so the APP needs to calculate the age by itself. However, we know that NSDateFormatter is a significant memory overhead object, and consumes a lot of memory during the list processing. Therefore, it is suggested that some things about computing should be better calculated on the server side, which is not only to ensure the performance of APP, but also a security problem!

Network security

Generally speaking, the network security problems of APP terminal are APP packet capture, DNS hijacking and server security. The details are as follows:

APP caught

When it comes to packet capture, the intruder can choose to grab data to steal the key data of the APP, and then simulate the request to do some things that the APP cannot control. Here we can use Https for network request, and we can also forbid network request setting code. Can also put the request header and request body encrypted transmission, more than one guarantee! But need to explain a point is that there is no absolute security, as long as it is designed to encrypt someone design decryption, peep in the heart!

DNS hijacking

DNS hijacking, because the domain name is resolved to IP based on UDP protocol, so the packet is in plaintext state, may be detected during the request process, and then the attacker does some own processing, such as returning a false IP address or doing nothing to make the request unresponsive. The effect is that a specific network cannot respond or access a fake url. There are two fundamental reasons:

A. Malicious attacks that intercept the parsing process of operators and embed their own illegal things in it.

B. Operators allow some third parties to advertise in their links for profit or other reasons.

How do I prevent DNS hijacking? Can be directly connected through the IP I said above, their own APP resolution! DNS DNS DNS DNS DNS DNS DNS

👉 DNS Optimization Practice of APP Network Optimization

Server security

Server security can be from the physical security and network security a. Physical security, the server to consider such as power, network and other circumstances caused by security problems; B. Network security, preventing the server from being attacked, crawler and other problems; Therefore, the server backup mechanism and data backup mechanism and important, but also to limit the number of requests and interval of the same IP;

conclusion

If there is not enough, I hope you are not stingy to give advice, you are also welcome to add group or call me QQ discussion exchange learning!