Partial html compression possible?

pawcuq
Posts: 6
Joined: Mon Dec 03, 2018 5:03 pm

Partial html compression possible?

Postby pawcuq » Sat Oct 09, 2021 9:48 am

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!

ESP_Sprite
Posts: 9719
Joined: Thu Nov 26, 2015 4:08 am

Re: Partial html compression possible?

Postby ESP_Sprite » Sun Oct 10, 2021 1:39 am

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?

pawcuq
Posts: 6
Joined: Mon Dec 03, 2018 5:03 pm

Re: Partial html compression possible?

Postby pawcuq » Sun Oct 10, 2021 4:39 am

That would be great but device will not have connection with the Internet so everything has to be on server side (ESP32).

ESP_Sprite
Posts: 9719
Joined: Thu Nov 26, 2015 4:08 am

Re: Partial html compression possible?

Postby ESP_Sprite » Mon Oct 11, 2021 12:57 am

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.

Who is online

Users browsing this forum: ignisuti and 82 guests