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:
@@ -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
|
||||
|
Reference in New Issue
Block a user