It turns it is basically a webkit talk… sigh
- DNS (SYN),
- HTTP GET request,
- the server answers HTTP OK
How long does it take to get the response back: latency. Two types on 3G/4G networks.
- initial connection setup: > 1s (on older 3G)
- Round trip time (RTT): 80ms or higher (typically) the common is 100ms to 200ms
Every new lookup takes 1 RTT + lookup time. These lookups are expensive and may take until 1s. Domain sharding. Use of multiple domains, requests will be sequential in fact and you will not improve the performances on mobile.
Browsers typically use 4-6 sockets per host. On Android, there is thread per socket model and do 4 HTTP threads at the same time. Only 4 sockets can have outstanding HTTP requests (“active”). It has an impact on all domains.
It is possible to use pipelining, Android does 3 requests at the time when pipelining. Pipelining is not implemented in major browsers except on Android.
HTTP Caching. Webkit maintains a memory cache. The default size is 8Mb. Android has a persistent (file system) HTTP Cache.
Cache eviction policy is also a source of performance. Android policy: Prioritize base on expiration date. Far future expiration dates have higher priority. Evict lowest priority items first. It has consequences.
Experiment by visiting different web sites with an initial clear cache.
sqlite3 webviewCache.db 'select expires from cacher order by expires desc;'
Expiration Year far in the future will never go away of the cache. This is a problem. Cache eviction policies affect performance.
Power is another issue for performances. Web pages strain the battery. Checking the battery power consumption along the page download is enlightning. Any network traffic brings up the radio for several seconds, around 10s-15s. Using long periods for any periodic Ajax calls, etc. If the call is happening every 15s, you might be consuming a lot of power.
TCP FINS and power. Android closes TCP sockets after 6s of inactivity (IDLE). Sockets get closed at different times. Every socket close generates a TCP FIN. extend the dormancy timer. Solution: Close all sockets after the page is downloaded.