diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index 4970248f..1e9e9c36 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -229,14 +229,32 @@ void serveIndexOrWelcome(AsyncWebServerRequest *request) } } +bool handleIfNoneMatchCacheHeader(AsyncWebServerRequest* request) +{ + AsyncWebHeader* header = request->getHeader("If-None-Match"); + if (header && header->value() == String(VERSION)) { + request->send(304); + return true; + } + return false; +} + +bool setStaticContentCacheHeaders(AsyncWebServerResponse *response) +{ + response->addHeader(F("Cache-Control"),"max-age=2592000"); + response->addHeader(F("ETag"), String(VERSION)); +} void serveIndex(AsyncWebServerRequest* request) { if (handleFileRead(request, "/index.htm")) return; + if (handleIfNoneMatchCacheHeader(request)) return; + AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_index, PAGE_index_L); response->addHeader(F("Content-Encoding"),"gzip"); + setStaticContentCacheHeaders(response); request->send(response); }