AT&T Video Optimizer
Text File Compression
Compressing text files makes them smaller and faster to send, and unzipping files on a mobile device has low overhead. So, it is recommended that you compress text files while they are being sent over wireless networks.
When compressing text files under 850 bytes, however, the extra overhead is not worth the effort, so the Best Practice recommendation is to compress text files over 850 bytes. This will speed downloads and text will render faster for users.
Compression is a technique for reducing the number of bits needed to store or transmit data. There are number of methods for compression available. The most broadly supported is gzip, which is very fast and has a small memory footprint.
Research has shown that compressing text files over 850 bytes will improve downloading enough to overcome overhead incurred in decompressing the files.
"HTTP 1.1 compression, which uses the gzip and DEFLATE algorithms, is widely supported. Web servers should be configured to serve appropriately compressed responses.
"Note however, that the cost (in time and battery usage) of decompressing data should be balanced against the gains in transport efficiency. When configuring HTTP 1.1 compression, note that:
- Most image formats (especially JPEGs) do not benefit from compression, but SVG does;
- Most other media formats (e.g. audio, video) do not benefit from compression;
- Very small files (e.g. <1k) generally do not benefit from compression."
Video Optimizer has a test that measures for uncompressed text files. If over 5% of an app’s text files are not compressed, Video Optimizer flags it.
A large percentage of mobile apps are serving text files uncompressed, which affects the app's performance.
In order to compress the files, compression needs to be supported, and there needs to be an agreement that it's alright to exchange compressed files. The agreement has two parts:
- The app sends a header telling the server it accepts compressed content. Accept-Encoding: gzip, deflate
- The server sends a response if the content is actually compressed: Content-Encoding: gzip
If the server doesn't send the content-encoding response header, it means the file will not be compressed, which is the default on many servers. The "Accept-encoding" header is just a request, not a demand. If the server does support compressed content, the app will accept the uncompressed version.
The most common compression schemas are 'gzip' and 'deflate'. Major mobile platforms support for gzip and deflate, but implementation will differ.
Best Practice Recommendation
Compressing large files will speed download, thus making the page render faster. The Best Practice Recommendation is to compress text files whenever possible.
You can use Video Optimizer to make sure you are compressing text files correctly. Video Optimizer runs automated tests for uncompressed text files:
If total size of all the uncompressed files in a trace = 0 -> Pass for Best Practice test If 0 < total size of all the uncompressed files a trace < 100 -> Warning for Best Practice test If total size of all the uncompressed files a trace >= 100 -> Fails the Best Practice test