We use GWT (Google Web Toolkit) in Tonido as the underlying HTML/JS technology for rendering our apps. The nice thing about GWT is that it allows you to work in HTML/JS land using a higher level language (Java) with full debugging support. The bad thing about GWT is that JS files can become pretty large (~500KB for example).
Now loading 500KB in a local network or machine is imperceptible, but on an internet connection, especially with a slow 50KBps upload, it can take a bunch of time before the Tonido UI becomes available. It was pretty annoying, and we just put off optimizing it because we weren’t sure what it would take to make it faster.
HTTP Accept-Encoding to the Rescue
Turns out there is a a quick and dirty way of making loading huge HTML/JS chunks faster. It is something in the HTTP specification called Accept-Encoding. Supported by most modern browsers, this tells a HTTP server that the browser can handle content that is compressed. By making a simple change to send compressed HTML/JS data back to the browser there is an incredible speedup. For example on an moderate internet connection, Tonido main page loaded originally at around 14 seconds. After this change, in a whopping low 7 seconds. (500 KB files get compressed down to ~150KB)
But, you might say, wait, isn’t the Tonido server going to do more work because of the extra compression? Yes if we did this on-the-fly, but not really. To put minimal stress on the CPU, we pre-compress the HTML/JS content in our release package before we ship. Tonido just reads it off the disk and sends it off. No on-the-fly compression.
It is a funny thing in software development, you can make huge performance leaps with small changes and then the gains get progressively smaller even after a lot of work. And at some point it is not even worth doing it. This change just proves the point.









