Page 1 of 1

Partial html compression possible?

Posted: Sat Oct 09, 2021 9:48 am
by pawcuq
Hello!

I have 15 html files, all of which uses a lot of JS linked locally and every html has different <body> (each file has about 100kB of <body>). I won't be able to store it inside ESP32 Flash without compression. I converted index.html into single file using https://github.com/remy/inliner and then to char array (about 1.5MB) and everything works fine when I use:

Code: Select all

httpd_resp_send(req, index_html_whole, HTTPD_RESP_USE_STRLEN);
When I gzip it and send using:

Code: Select all

httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
httpd_resp_set_type(req, "text/html");
httpd_resp_send(req, index_html_whole_gz, HTTPD_RESP_USE_STRLEN);
also everything works fine.

And here's my question: If I cut out <body> part from index.html and save it in another file, can I compress them separately and send them to browser? Because JS and CSS part is common for all html files I would save enormous amount of Flash space. If that appoach is correct which functions should I use? Thanks!

Re: Partial html compression possible?

Posted: Sun Oct 10, 2021 1:39 am
by ESP_Sprite
If JS and CSS are common, why not take them out of the html into separate x.js and x.css files and include them using the html code, instead of combining them on the server side?

Re: Partial html compression possible?

Posted: Sun Oct 10, 2021 4:39 am
by pawcuq
That would be great but device will not have connection with the Internet so everything has to be on server side (ESP32).

Re: Partial html compression possible?

Posted: Mon Oct 11, 2021 12:57 am
by ESP_Sprite
Obviously, however if you serve those separate js and css files from the ESP32 as well, there should not be a need to have online connectivity.