Recently I have found a great solution for implementing a HTTP server in devices with limited memory (like the ones based on USBizi chip). The problem I faced when implementing one was that when the device is serving pages/scripts/images/etc it needs to load them to memory from internal resources or e.g. sd card, and save them to the result stream. It all involves a lot of memory as it’s easy for html or javascript files to have 10KB+. For USBizi that’s a lot. At the beginning i was only using minified javascript libraries and i guess there are also tool to minify my own html files as well. While investigating options i have found a simple yet perfect solution for this problem: using GZIP! The idea is simple, you only store the compressed versions of your files on the device. When your web server sends a response, just include this header:
context.Response.Headers.Set("Content-Encoding", "gzip");
Modern browser will decompress the file before rendering it. This operation is transparent for the user. This option can be turned on in IIS or Apache, I just wasn’t aware of it and how well it fits to our low memory constraints. I hope you can benefit from this. For those of you who already know that, sory for wasting your time