diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index 0f7a7956..8424e2c5 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -107,8 +107,8 @@ const char HTTP_DOCTYPE[] PROGMEM = "
";
const char HTTP_META_GO_BACK[] PROGMEM = "";
const char HTTP_HEADER[] PROGMEM = "%s";
-const char HTTP_STYLE[] PROGMEM =
- "";
+ "td{font-size:0.87rem;padding-bottom:0px;padding-top:0px;}th{padding-top:0.5em;}";
const char HTTP_SCRIPT[] PROGMEM = "";
@@ -265,6 +263,17 @@ void webSendFooter()
#endif
}
+int webSendCached(int statuscode, char* contenttype, char* data, size_t size)
+{
+ webServer.sendHeader(F("Cache-Control"), F("public, max-age=604800, immutable"));
+#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ webServer.send_P(statuscode, contenttype, data, size);
+#else
+ webServer.send(statuscode, contenttype, data);
+#endif
+ return statuscode;
+}
+
void webSendPage(const char* nodename, uint32_t httpdatalength, bool gohome = false)
{
{
@@ -989,15 +998,12 @@ int handleFileRead(String path)
if(path == F("/edit.htm")) {
size_t size = EDIT_HTM_GZ_END - EDIT_HTM_GZ_START;
webServer.sendHeader(F("Content-Encoding"), F("gzip"));
- webServer.send_P(200, PSTR("text/html"), (const char*)EDIT_HTM_GZ_START, size);
- return 200; // OK
+ return webSendCached(200, PSTR("text/html"), (const char*)EDIT_HTM_GZ_START, size); // OK
}
#endif
- if(!strcasecmp_P(path.c_str(), PSTR("/favicon.ico"))) {
- webServer.send_P(204, PSTR("image/bmp"), "", 0); // No content
- return 204;
- }
+ if(!strcasecmp_P(path.c_str(), PSTR("/favicon.ico")))
+ return webSendCached(204, PSTR("image/bmp"), "", 0); // No content
return 404; // Not found
}
@@ -1908,17 +1914,15 @@ void httpHandleNotFound()
int statuscode = 404;
#endif
- if(statuscode == 204) return; // No content
-
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
LOG_TRACE(TAG_HTTP, F("Sending %d %s to client connected from: %s"), statuscode, webServer.uri().c_str(),
webServer.client().remoteIP().toString().c_str());
#else
- // LOG_TRACE(TAG_HTTP,F("Sending 404 to client connected from: %s"),
- // String(webServer.client().remoteIP()).c_str());
+ // LOG_TRACE(TAG_HTTP,F("Sending 404 to client connected from: %s"),
+ // String(webServer.client().remoteIP()).c_str());
#endif
- if(statuscode == 200) return; // OK
+ if(statuscode < 300) return; // OK
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
@@ -2112,6 +2116,7 @@ void httpSetup()
// Shared pages
webServer.on(F("/about"), webHandleAbout);
+ webServer.on(F("/css"), []() { webSendCached(200, PSTR("text/css"), HTTP_CSS, sizeof(HTTP_CSS) - 1); });
webServer.onNotFound(httpHandleNotFound);
#if HASP_USE_WIFI > 0