Use gzip compression for the web server component's static resources (#5291)

Co-authored-by: Daniel Dunn <dannydunn@eternityforest.com>
This commit is contained in:
Daniel DunnandDaniel Dunn authored and GitHub committed 2023-09-01 14:02:26 +12:00
1 parent f14419bab5
commit 19d53c6643
3 files changed
+15 -2

No files matched your search

@@ -328,6 +328,7 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
void WebServer::handle_index_request(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response =
request->beginResponse_P(200, "text/html", ESPHOME_WEBSERVER_INDEX_HTML, ESPHOME_WEBSERVER_INDEX_HTML_SIZE);
// No gzip header here because the HTML file is so small
request->send(response);
}
#endif
@@ -336,6 +337,7 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
void WebServer::handle_css_request(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response =
request->beginResponse_P(200, "text/css", ESPHOME_WEBSERVER_CSS_INCLUDE, ESPHOME_WEBSERVER_CSS_INCLUDE_SIZE);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}
#endif
@@ -344,6 +346,7 @@ void WebServer::handle_css_request(AsyncWebServerRequest *request) {
void WebServer::handle_js_request(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response =
request->beginResponse_P(200, "text/javascript", ESPHOME_WEBSERVER_JS_INCLUDE, ESPHOME_WEBSERVER_JS_INCLUDE_SIZE);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}
#endif