static html compression

Hi,

I'm getting to the 32K limit of program size on a uno.

Yes I have a lot of thing in my program, including http server, and yes I could go for a bigger arduino mega.

But no... I want to optimize... :wink:

My idea : instead of storing static html string pieces, and concatenate with variables while printing, I was thinking about having a single, full static html file, including js to that fill the dynamic parts of the page with ajax, arduino replying to the ajax request with a much simpler structure.

... And, it's where I expect to gain on program size, send the static html/js file compressed in gzip.
The idea is to of course compress the static file before compilation, and store the compressed (binary) data.
Arduino send dumbly static data without being able to compress/decompress.

1/ Did someone already do this?
2/ Is there any way to simplify the compilation, like a precompiler operation that gzip an external html file, and include the binary compressed file in program space....

3/ Or simpler, a script that gzip a file, and convert the result in a copy/pastable string that I can put in the arduino source code.

Thanks,

I think there are a lot of HTML compressor utilities in early ages when Internet is basically connected with 56K modem. What is also needed is a utility that reads gzip console output and encode to C array.
But, I really don't think this is worth the effort. Why not keep the static page in a SD card or just in the cloud? Arduino should just feed data not the static page if it is connected to Internet.

Shrinking code by added more code turns out to be not very efficient.
Adding the SD library will make you run out of memory even quicker :confused:
Is most of the code size perhaps HTML code in PROGMEM ? Could you use a single definition for the first part of a html page ? With the header and maybe the start code for a page ?

The -flto option can be added to the compiler, it shrinks a sketch by 5% to 20%.

Using bytes (instead of int) saves ram and code memory. I'm sure there are many ways to get a few extra free bytes in many parts of the code.