1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-09 14:52:20 +01:00

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 Dunn
2023-08-31 20:02:26 -06:00
committed by GitHub
parent f14419bab5
commit 19d53c6643
3 changed files with 15 additions and 2 deletions

View File

@@ -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